Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f01a4710 authored by John Reck's avatar John Reck Committed by Android Git Automerger
Browse files

am 1e2063fb: am d1b16386: am 2c7ed6e8: Merge "Improve ImageView drawable re-use" into mnc-dev

* commit '1e2063fb':
  Improve ImageView drawable re-use
parents ee3c1ea5 1e2063fb
Loading
Loading
Loading
Loading
+13 −10
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ public class ImageView extends View {
    private boolean mColorMod = false;

    private Drawable mDrawable = null;
    private ImageViewBitmapDrawable mRecycleableBitmapDrawable = null;
    private ColorStateList mDrawableTintList = null;
    private PorterDuff.Mode mDrawableTintMode = null;
    private boolean mHasDrawableTint = false;
@@ -588,18 +589,16 @@ public class ImageView extends View {
     */
    @android.view.RemotableViewMethod
    public void setImageBitmap(Bitmap bm) {
        // if this is used frequently, may handle bitmaps explicitly
        // to reduce the intermediate drawable object
        if (mDrawable instanceof ImageViewBitmapDrawable) {
            ImageViewBitmapDrawable recycledDrawable = (ImageViewBitmapDrawable) mDrawable;
        // Hacky fix to force setImageDrawable to do a full setImageDrawable
        // instead of doing an object reference comparison
        mDrawable = null;
            recycledDrawable.setBitmap(bm);
            setImageDrawable(recycledDrawable);
        if (mRecycleableBitmapDrawable == null) {
            mRecycleableBitmapDrawable = new ImageViewBitmapDrawable(
                    mContext.getResources(), bm);
        } else {
            setImageDrawable(new ImageViewBitmapDrawable(mContext.getResources(), bm));
            mRecycleableBitmapDrawable.setBitmap(bm);
        }
        setImageDrawable(mRecycleableBitmapDrawable);
    }

    public void setImageState(int[] state, boolean merge) {
@@ -868,6 +867,10 @@ public class ImageView extends View {
    }

    private void updateDrawable(Drawable d) {
        if (d != mRecycleableBitmapDrawable && mRecycleableBitmapDrawable != null) {
            mRecycleableBitmapDrawable.setBitmap(null);
        }

        if (mDrawable != null) {
            mDrawable.setCallback(null);
            unscheduleDrawable(mDrawable);