Skip to content

Commit

Permalink
Merge pull request #6346 from Imericxu/tabs-style-check
Browse files Browse the repository at this point in the history
Resolve Tabs style checks
  • Loading branch information
Stypox authored Jun 8, 2021
2 parents 0b64382 + a2fd5ae commit a2eead5
Showing 1 changed file with 55 additions and 16 deletions.
71 changes: 55 additions & 16 deletions app/src/main/java/org/schabi/newpipe/settings/tabs/Tab.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,16 @@ private static Tab from(final int tabId, @Nullable final JsonObject jsonObject)

@Override
public boolean equals(final Object obj) {
if (obj == this) {
return true;
if (!(obj instanceof Tab)) {
return false;
}
final Tab other = (Tab) obj;
return getTabId() == other.getTabId();
}

return obj instanceof Tab && obj.getClass() == this.getClass()
&& ((Tab) obj).getTabId() == this.getTabId();
@Override
public int hashCode() {
return Objects.hashCode(getTabId());
}

/*//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -358,8 +362,18 @@ protected void readDataFromJson(final JsonObject jsonObject) {

@Override
public boolean equals(final Object obj) {
return super.equals(obj) && kioskServiceId == ((KioskTab) obj).kioskServiceId
&& Objects.equals(kioskId, ((KioskTab) obj).kioskId);
if (!(obj instanceof KioskTab)) {
return false;
}
final KioskTab other = (KioskTab) obj;
return super.equals(obj)
&& kioskServiceId == other.kioskServiceId
&& kioskId.equals(other.kioskId);
}

@Override
public int hashCode() {
return Objects.hash(getTabId(), kioskServiceId, kioskId);
}

public int getKioskServiceId() {
Expand Down Expand Up @@ -432,9 +446,19 @@ protected void readDataFromJson(final JsonObject jsonObject) {

@Override
public boolean equals(final Object obj) {
return super.equals(obj) && channelServiceId == ((ChannelTab) obj).channelServiceId
&& Objects.equals(channelUrl, ((ChannelTab) obj).channelUrl)
&& Objects.equals(channelName, ((ChannelTab) obj).channelName);
if (!(obj instanceof ChannelTab)) {
return false;
}
final ChannelTab other = (ChannelTab) obj;
return super.equals(obj)
&& channelServiceId == other.channelServiceId
&& channelUrl.equals(other.channelName)
&& channelName.equals(other.channelName);
}

@Override
public int hashCode() {
return Objects.hash(getTabId(), channelServiceId, channelUrl, channelName);
}

public int getChannelServiceId() {
Expand Down Expand Up @@ -576,15 +600,30 @@ 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;
}

return (playlistId == ((PlaylistTab) obj).playlistId) // local
|| (playlistServiceId == ((PlaylistTab) obj).playlistServiceId // remote
&& Objects.equals(playlistUrl, ((PlaylistTab) obj).playlistUrl));
final PlaylistTab other = (PlaylistTab) obj;

return super.equals(obj)
&& playlistServiceId == other.playlistServiceId // Remote
&& playlistId == other.playlistId // Local
&& playlistUrl.equals(other.playlistUrl)
&& playlistName.equals(other.playlistName)
&& playlistType == other.playlistType;
}

@Override
public int hashCode() {
return Objects.hash(
getTabId(),
playlistServiceId,
playlistId,
playlistUrl,
playlistName,
playlistType
);
}

public int getPlaylistServiceId() {
Expand Down

0 comments on commit a2eead5

Please sign in to comment.