android: fix when reuse image'drawable may cause crash in some devices

This commit is contained in:
pengfei.zhou 2022-06-06 10:42:45 +08:00 committed by osborn
parent 34b759bb82
commit 6efd008841

View File

@ -297,6 +297,11 @@ public class ImageNode extends ViewNode<ImageView> {
Drawable placeHolderDrawable = null;
if (mView.getDrawable() != null) {
placeHolderDrawable = mView.getDrawable();
if (placeHolderDrawable instanceof BitmapDrawable) {
Bitmap bitmap = ((BitmapDrawable) placeHolderDrawable).getBitmap();
Bitmap newBitmap = bitmap.copy(Bitmap.Config.ARGB_8888, false);
placeHolderDrawable = new BitmapDrawable(newBitmap);
}
} else {
placeHolderDrawable = getPlaceHolderDrawable();
}