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

Commit bcb9118e authored by Jernej Virag's avatar Jernej Virag
Browse files

Don't load resource drawables just to compare them

Resource IDs are stable and `Icon` class does a good job comparing them. Don't load drawables just to figure out that a resource with same ID in same package is actually the same thing.

Bug:421974887
Flag: EXEMPT bugfix
Test: presubmit
Change-Id: Id8c05e0554955540b20676769ac776b18f4d0a7f
parent 1028f413
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -131,7 +131,11 @@ private fun areIconsEqual(context: Context, new: Icon?, old: Icon?): Boolean {
            Log.e(TAG, "Cannot compare recycled bitmap")
            return false
        }
        new.bitmap.sameAs(old.bitmap)
        // Icon.sameAs checks for Bitmap reference equality - faster if its
        // actually equal.
        new.sameAs(old) || new.bitmap.sameAs(old.bitmap)
    } else if (new.type == Icon.TYPE_DATA || new.type == Icon.TYPE_RESOURCE) {
        return new.sameAs(old);
    } else {
        val newDrawable = new.loadDrawable(context)
        val oldDrawable = old.loadDrawable(context)