Introduce constants for some Strings that indicate no data in Tab class
This commit is contained in:
parent
a163d5461d
commit
d71af9a625
1 changed files with 16 additions and 10 deletions
|
@ -36,6 +36,10 @@ import java.util.Objects;
|
||||||
public abstract class Tab {
|
public abstract class Tab {
|
||||||
private static final String JSON_TAB_ID_KEY = "tab_id";
|
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() {
|
Tab() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +189,9 @@ public abstract class Tab {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTabName(final Context context) {
|
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
|
@DrawableRes
|
||||||
|
@ -309,7 +315,7 @@ public abstract class Tab {
|
||||||
private String kioskId;
|
private String kioskId;
|
||||||
|
|
||||||
private KioskTab() {
|
private KioskTab() {
|
||||||
this(-1, "<no-id>");
|
this(-1, NO_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public KioskTab(final int kioskServiceId, final String kioskId) {
|
public KioskTab(final int kioskServiceId, final String kioskId) {
|
||||||
|
@ -357,7 +363,7 @@ public abstract class Tab {
|
||||||
@Override
|
@Override
|
||||||
protected void readDataFromJson(final JsonObject jsonObject) {
|
protected void readDataFromJson(final JsonObject jsonObject) {
|
||||||
kioskServiceId = jsonObject.getInt(JSON_KIOSK_SERVICE_ID_KEY, -1);
|
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
|
@Override
|
||||||
|
@ -395,7 +401,7 @@ public abstract class Tab {
|
||||||
private String channelName;
|
private String channelName;
|
||||||
|
|
||||||
private ChannelTab() {
|
private ChannelTab() {
|
||||||
this(-1, "<no-url>", "<no-name>");
|
this(-1, NO_URL, NO_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChannelTab(final int channelServiceId, final String channelUrl,
|
public ChannelTab(final int channelServiceId, final String channelUrl,
|
||||||
|
@ -440,8 +446,8 @@ public abstract class Tab {
|
||||||
@Override
|
@Override
|
||||||
protected void readDataFromJson(final JsonObject jsonObject) {
|
protected void readDataFromJson(final JsonObject jsonObject) {
|
||||||
channelServiceId = jsonObject.getInt(JSON_CHANNEL_SERVICE_ID_KEY, -1);
|
channelServiceId = jsonObject.getInt(JSON_CHANNEL_SERVICE_ID_KEY, -1);
|
||||||
channelUrl = jsonObject.getString(JSON_CHANNEL_URL_KEY, "<no-url>");
|
channelUrl = jsonObject.getString(JSON_CHANNEL_URL_KEY, NO_URL);
|
||||||
channelName = jsonObject.getString(JSON_CHANNEL_NAME_KEY, "<no-name>");
|
channelName = jsonObject.getString(JSON_CHANNEL_NAME_KEY, NO_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -527,7 +533,7 @@ public abstract class Tab {
|
||||||
private LocalItemType playlistType;
|
private LocalItemType playlistType;
|
||||||
|
|
||||||
private PlaylistTab() {
|
private PlaylistTab() {
|
||||||
this(-1, "<no-name>");
|
this(-1, NO_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlaylistTab(final long playlistId, final String playlistName) {
|
public PlaylistTab(final long playlistId, final String playlistName) {
|
||||||
|
@ -535,7 +541,7 @@ public abstract class Tab {
|
||||||
this.playlistId = playlistId;
|
this.playlistId = playlistId;
|
||||||
this.playlistType = LocalItemType.PLAYLIST_LOCAL_ITEM;
|
this.playlistType = LocalItemType.PLAYLIST_LOCAL_ITEM;
|
||||||
this.playlistServiceId = -1;
|
this.playlistServiceId = -1;
|
||||||
this.playlistUrl = "<no-url>";
|
this.playlistUrl = NO_URL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlaylistTab(final int playlistServiceId, final String playlistUrl,
|
public PlaylistTab(final int playlistServiceId, final String playlistUrl,
|
||||||
|
@ -589,8 +595,8 @@ public abstract class Tab {
|
||||||
@Override
|
@Override
|
||||||
protected void readDataFromJson(final JsonObject jsonObject) {
|
protected void readDataFromJson(final JsonObject jsonObject) {
|
||||||
playlistServiceId = jsonObject.getInt(JSON_PLAYLIST_SERVICE_ID_KEY, -1);
|
playlistServiceId = jsonObject.getInt(JSON_PLAYLIST_SERVICE_ID_KEY, -1);
|
||||||
playlistUrl = jsonObject.getString(JSON_PLAYLIST_URL_KEY, "<no-url>");
|
playlistUrl = jsonObject.getString(JSON_PLAYLIST_URL_KEY, NO_URL);
|
||||||
playlistName = jsonObject.getString(JSON_PLAYLIST_NAME_KEY, "<no-name>");
|
playlistName = jsonObject.getString(JSON_PLAYLIST_NAME_KEY, NO_NAME);
|
||||||
playlistId = jsonObject.getInt(JSON_PLAYLIST_ID_KEY, -1);
|
playlistId = jsonObject.getInt(JSON_PLAYLIST_ID_KEY, -1);
|
||||||
playlistType = LocalItemType.valueOf(
|
playlistType = LocalItemType.valueOf(
|
||||||
jsonObject.getString(JSON_PLAYLIST_TYPE_KEY,
|
jsonObject.getString(JSON_PLAYLIST_TYPE_KEY,
|
||||||
|
|
Loading…
Add table
Reference in a new issue