static void setCreatedFromResId(Resources resources, int id, Drawable drawable) { // todo: this kinda sucks, find some better way... if (drawable != null && Shadow.extract(drawable) instanceof ShadowDrawable) { ShadowDrawable shadowDrawable = Shadow.extract(drawable); shadowDrawable.createdFromResId = id; if (drawable instanceof BitmapDrawable) { Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap(); if (bitmap != null && Shadow.extract(bitmap) instanceof ShadowBitmap) { ShadowBitmap shadowBitmap = Shadow.extract(bitmap); if (shadowBitmap.createdFromResId == -1) { String resourceName; try { resourceName = resources.getResourceName(id); } catch (NotFoundException e) { resourceName = "Unknown resource #0x" + Integer.toHexString(id); } shadowBitmap.setCreatedFromResId(id, resourceName); } } } } }
static void setCreatedFromResId(Resources resources, int id, Drawable drawable) { // todo: this kinda sucks, find some better way... if (drawable != null) { shadowOf(drawable).createdFromResId = id; if (drawable instanceof BitmapDrawable) { Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap(); if (bitmap != null) { ShadowBitmap shadowBitmap = shadowOf(bitmap); if (shadowBitmap.createdFromResId == -1) { shadowBitmap.setCreatedFromResId(id, shadowOf(resources.getAssets()).getResourceName(id)); } } } } }
static void setCreatedFromResId(Resources resources, int id, Drawable drawable) { // todo: this kinda sucks, find some better way... if (drawable != null) { shadowOf(drawable).createdFromResId = id; if (drawable instanceof BitmapDrawable) { Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap(); if (bitmap != null) { ShadowBitmap shadowBitmap = shadowOf(bitmap); if (shadowBitmap.createdFromResId == -1) { shadowBitmap.setCreatedFromResId(id, shadowOf(resources.getAssets()).getResourceName(id)); } } } } }
static void setCreatedFromResId(Resources resources, int id, Drawable drawable) { // todo: this kinda sucks, find some better way... if (drawable != null && Shadow.extract(drawable) instanceof ShadowDrawable) { ShadowDrawable shadowDrawable = Shadow.extract(drawable); shadowDrawable.createdFromResId = id; if (drawable instanceof BitmapDrawable) { Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap(); if (bitmap != null && Shadow.extract(bitmap) instanceof ShadowBitmap) { ShadowBitmap shadowBitmap = Shadow.extract(bitmap); if (shadowBitmap.createdFromResId == -1) { String resourceName; try { resourceName = resources.getResourceName(id); } catch (NotFoundException e) { resourceName = "Unknown resource #0x" + Integer.toHexString(id); } shadowBitmap.setCreatedFromResId(id, resourceName); } } } } }
@HiddenApi @Implementation public Drawable loadDrawable(TypedValue value, int id) { Drawable drawable = directlyOn(realResources, Resources.class, "loadDrawable", ClassParameter.from(TypedValue.class, value), ClassParameter.from(int.class, id)); // todo: this kinda sucks, find some better way... if (drawable != null) { shadowOf(drawable).createdFromResId = id; if (drawable instanceof BitmapDrawable) { Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap(); if (bitmap != null) { ShadowBitmap shadowBitmap = shadowOf(bitmap); if (shadowBitmap.createdFromResId == -1) { shadowBitmap.setCreatedFromResId(id, shadowOf(realResources.getAssets()).getResourceName(id)); } } } } return drawable; }
@Implementation public Drawable loadDrawable(TypedValue value, int id, Resources.Theme theme) throws Resources.NotFoundException { Drawable drawable = directlyOn(realResources, Resources.class, "loadDrawable", ClassParameter.from(TypedValue.class, value), ClassParameter.from(int.class, id), ClassParameter.from(Resources.Theme.class, theme)); // todo: this kinda sucks, find some better way... if (drawable != null) { shadowOf(drawable).createdFromResId = id; if (drawable instanceof BitmapDrawable) { Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap(); if (bitmap != null) { ShadowBitmap shadowBitmap = shadowOf(bitmap); if (shadowBitmap.createdFromResId == -1) { shadowBitmap.setCreatedFromResId(id, shadowOf(realResources.getAssets()).getResourceName(id)); } } } } return drawable; }