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

Commit d1af8469 authored by Ioana Alexandru's avatar Ioana Alexandru
Browse files

Remove redundant val from Icon#equals

We can rely on smart casting and don't need to use a separate val here.

Bug: NA
Test: existing tests pass
Flag: EXEMPT minor cleanup
Change-Id: I1b4fa593a5d28386511b7902b37d0866931c4a64
parent c2dba8df
Loading
Loading
Loading
Loading
+11 −9
Original line number Diff line number Diff line
@@ -66,21 +66,23 @@ sealed class Icon {
        }

        override fun equals(other: Any?): Boolean {
            val that = other as? Loaded ?: return false
            if (other !is Loaded) {
                return false
            }

            // If both icons provide a resId, only use package+resId for identification, so that
            // drawable copies or mutations of the same base resource are considered equal.
            if (this.resId != null && that.resId != null) {
                return this.resId == that.resId &&
                    this.packageName == that.packageName &&
                    this.contentDescription == that.contentDescription
            if (this.resId != null && other.resId != null) {
                return this.resId == other.resId &&
                    this.packageName == other.packageName &&
                    this.contentDescription == other.contentDescription
            }

            // Otherwise, compare everything.
            return this.resId == that.resId &&
                this.packageName == that.packageName &&
                this.drawable == that.drawable &&
                this.contentDescription == that.contentDescription
            return this.resId == other.resId &&
                this.packageName == other.packageName &&
                this.drawable == other.drawable &&
                this.contentDescription == other.contentDescription
        }

        override fun hashCode(): Int {