Skip to content

Commit

Permalink
Introduce constants for some Strings that indicate no data in Tab class
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiGr committed Dec 21, 2021
1 parent a163d54 commit d71af9a
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions app/src/main/java/org/schabi/newpipe/settings/tabs/Tab.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
public abstract class Tab {
private static final String JSON_TAB_ID_KEY = "tab_id";

private static final String NO_NAME = "<no-name>";
private static final String NO_ID = "<no-id>";
private static final String NO_URL = "<no-url>";

Tab() {
}

Expand Down Expand Up @@ -185,7 +189,9 @@ public int getTabId() {

@Override
public String getTabName(final Context context) {
return "NewPipe"; //context.getString(R.string.blank_page_summary);
// TODO: find a better name for the blank tab (maybe "blank_tab") or replace it with
// context.getString(R.string.app_name);
return "NewPipe"; // context.getString(R.string.blank_page_summary);
}

@DrawableRes
Expand Down Expand Up @@ -309,7 +315,7 @@ public static class KioskTab extends Tab {
private String kioskId;

private KioskTab() {
this(-1, "<no-id>");
this(-1, NO_ID);
}

public KioskTab(final int kioskServiceId, final String kioskId) {
Expand Down Expand Up @@ -357,7 +363,7 @@ protected void writeDataToJson(final JsonSink writerSink) {
@Override
protected void readDataFromJson(final JsonObject jsonObject) {
kioskServiceId = jsonObject.getInt(JSON_KIOSK_SERVICE_ID_KEY, -1);
kioskId = jsonObject.getString(JSON_KIOSK_ID_KEY, "<no-id>");
kioskId = jsonObject.getString(JSON_KIOSK_ID_KEY, NO_ID);
}

@Override
Expand Down Expand Up @@ -395,7 +401,7 @@ public static class ChannelTab extends Tab {
private String channelName;

private ChannelTab() {
this(-1, "<no-url>", "<no-name>");
this(-1, NO_URL, NO_NAME);
}

public ChannelTab(final int channelServiceId, final String channelUrl,
Expand Down Expand Up @@ -440,8 +446,8 @@ protected void writeDataToJson(final JsonSink writerSink) {
@Override
protected void readDataFromJson(final JsonObject jsonObject) {
channelServiceId = jsonObject.getInt(JSON_CHANNEL_SERVICE_ID_KEY, -1);
channelUrl = jsonObject.getString(JSON_CHANNEL_URL_KEY, "<no-url>");
channelName = jsonObject.getString(JSON_CHANNEL_NAME_KEY, "<no-name>");
channelUrl = jsonObject.getString(JSON_CHANNEL_URL_KEY, NO_URL);
channelName = jsonObject.getString(JSON_CHANNEL_NAME_KEY, NO_NAME);
}

@Override
Expand Down Expand Up @@ -527,15 +533,15 @@ public static class PlaylistTab extends Tab {
private LocalItemType playlistType;

private PlaylistTab() {
this(-1, "<no-name>");
this(-1, NO_NAME);
}

public PlaylistTab(final long playlistId, final String playlistName) {
this.playlistName = playlistName;
this.playlistId = playlistId;
this.playlistType = LocalItemType.PLAYLIST_LOCAL_ITEM;
this.playlistServiceId = -1;
this.playlistUrl = "<no-url>";
this.playlistUrl = NO_URL;
}

public PlaylistTab(final int playlistServiceId, final String playlistUrl,
Expand Down Expand Up @@ -589,8 +595,8 @@ protected void writeDataToJson(final JsonSink writerSink) {
@Override
protected void readDataFromJson(final JsonObject jsonObject) {
playlistServiceId = jsonObject.getInt(JSON_PLAYLIST_SERVICE_ID_KEY, -1);
playlistUrl = jsonObject.getString(JSON_PLAYLIST_URL_KEY, "<no-url>");
playlistName = jsonObject.getString(JSON_PLAYLIST_NAME_KEY, "<no-name>");
playlistUrl = jsonObject.getString(JSON_PLAYLIST_URL_KEY, NO_URL);
playlistName = jsonObject.getString(JSON_PLAYLIST_NAME_KEY, NO_NAME);
playlistId = jsonObject.getInt(JSON_PLAYLIST_ID_KEY, -1);
playlistType = LocalItemType.valueOf(
jsonObject.getString(JSON_PLAYLIST_TYPE_KEY,
Expand Down

0 comments on commit d71af9a

Please sign in to comment.