Skip to content

Commit

Permalink
Refactor PlaylistTab.equals
Browse files Browse the repository at this point in the history
  • Loading branch information
imericxu committed May 24, 2021
1 parent d4f0f79 commit 7b8778b
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions app/src/main/java/org/schabi/newpipe/settings/tabs/Tab.java
Original file line number Diff line number Diff line change
Expand Up @@ -600,15 +600,22 @@ protected void readDataFromJson(final JsonObject jsonObject) {

@Override
public boolean equals(final Object obj) {
if (!(super.equals(obj)
&& Objects.equals(playlistType, ((PlaylistTab) obj).playlistType)
&& Objects.equals(playlistName, ((PlaylistTab) obj).playlistName))) {
return false; // base objects are different
if (!(obj instanceof PlaylistTab)) {
return false;
}

final PlaylistTab other = (PlaylistTab) obj;

if (!(super.equals(obj))) {
// Base objects are different
return false;
}

return (playlistId == ((PlaylistTab) obj).playlistId) // local
|| (playlistServiceId == ((PlaylistTab) obj).playlistServiceId // remote
&& Objects.equals(playlistUrl, ((PlaylistTab) obj).playlistUrl));
return playlistServiceId == other.playlistServiceId // Remote
&& playlistId == other.playlistId // Local
&& playlistUrl.equals(other.playlistUrl)
&& playlistName.equals(other.playlistName)
&& playlistType == other.playlistType;
}

public int getPlaylistServiceId() {
Expand Down

0 comments on commit 7b8778b

Please sign in to comment.