From 96d731dfc7e265cd0333499d70f6a13c3515e81c Mon Sep 17 00:00:00 2001 From: Eric Xu Date: Sat, 22 May 2021 00:06:59 -0400 Subject: [PATCH] Refactor equals method --- .../main/java/org/schabi/newpipe/settings/tabs/Tab.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/settings/tabs/Tab.java b/app/src/main/java/org/schabi/newpipe/settings/tabs/Tab.java index b289009ce..faa5aeba9 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/tabs/Tab.java +++ b/app/src/main/java/org/schabi/newpipe/settings/tabs/Tab.java @@ -112,12 +112,11 @@ public abstract class Tab { @Override public boolean equals(final Object obj) { - if (obj == this) { - return true; + if (!(obj instanceof Tab)) { + return false; } - - return obj instanceof Tab && obj.getClass() == this.getClass() - && ((Tab) obj).getTabId() == this.getTabId(); + final Tab other = (Tab) obj; + return getTabId() == other.getTabId(); } /*//////////////////////////////////////////////////////////////////////////