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

Commit 94246118 authored by Fabián Kozynski's avatar Fabián Kozynski
Browse files

Add equality to DrawableIcon

If two DrawableIcons are created with the same DrawableIcon, then they
will be equal.

Test: manual using a toggle custom tile (no regressions).
Bug: 361558581
Bug: 361611824
Flag: EXEMPT bugfix
Change-Id: Ia045d0997417005a93dd4caa4ff58937036c1ff1
parent f4883225
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ import com.android.systemui.qs.SideLabelTileLayout;
import com.android.systemui.qs.logging.QSLogger;

import java.io.PrintWriter;
import java.util.Objects;

/**
 * Base quick-settings tile, extend this to create a new tile.
@@ -667,6 +668,18 @@ public abstract class QSTileImpl<TState extends State> implements QSTile, Lifecy
        public String toString() {
            return "DrawableIcon";
        }

        @Override
        public boolean equals(@Nullable Object other) {
            // No need to compare equality of the mInvisibleDrawable as that's generated from
            // mDrawable's constant state.
            return other instanceof DrawableIcon && ((DrawableIcon) other).mDrawable == mDrawable;
        }

        @Override
        public int hashCode() {
            return Objects.hash(mDrawable);
        }
    }

    public static class DrawableIconWithRes extends DrawableIcon {