1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-03 23:40:30 +01:00

Fixed icons and tab titles

This commit is contained in:
Somethingweirdhere 2018-06-11 11:01:18 +02:00 committed by Christian Schabesberger
parent 5cb7771484
commit be62a2bfc5
3 changed files with 79 additions and 9 deletions

View File

@ -117,6 +117,50 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
viewPager.setOffscreenPageLimit(adapter.getCount()); viewPager.setOffscreenPageLimit(adapter.getCount());
setIcons(); setIcons();
setFirstTitle();
}
private void setFirstTitle() {
if((tabs.size()>0)&&activity != null) {
String tabNumber = tabs.get(0);
if (tabNumber.startsWith("1\t")) {
String kiosk[] = tabNumber.split("\t");
if (kiosk.length == 2) {
try {
setTitle(kiosk[1]);
} catch (Exception e) {
//ignore this. It WILL be thrown while the service is changed.
}
}
} else if (tabNumber.startsWith("6\t")) {
String channelInfo[] = tabNumber.split("\t");
if(channelInfo.length==4) {
setTitle(channelInfo[2]);
}
} else {
switch (tabNumber) {
case "0":
setTitle(getString(R.string.app_name));
break;
case "2":
setTitle(getString(R.string.tab_subscriptions));
break;
case "3":
setTitle(getString(R.string.fragment_whats_new));
break;
case "4":
setTitle(getString(R.string.tab_bookmarks));
break;
case "5":
setTitle(getString(R.string.title_activity_history));
break;
}
}
}
} }
private void setIcons() { private void setIcons() {
@ -138,19 +182,23 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
} }
} else if (tabNumber.startsWith("6\t")) { } else if (tabNumber.startsWith("6\t")) {
tabToSet.setIcon(R.drawable.ic_channel_white_24dp); tabToSet.setIcon(R.drawable.ic_channel_white_24dp);
} else { } else {
switch (tabNumber) { switch (tabNumber) {
case "0": case "0":
tabToSet.setIcon(R.drawable.ic_whatshot_white_24dp); tabToSet.setIcon(R.drawable.ic_whatshot_white_24dp);
break;
case "2": case "2":
tabToSet.setIcon(R.drawable.ic_channel_white_24dp); tabToSet.setIcon(R.drawable.ic_channel_white_24dp);
break;
case "3": case "3":
tabToSet.setIcon(R.drawable.ic_rss_feed_white_24dp); tabToSet.setIcon(R.drawable.ic_rss_feed_white_24dp);
break;
case "4": case "4":
tabToSet.setIcon(R.drawable.ic_bookmark_white_24dp); tabToSet.setIcon(R.drawable.ic_bookmark_white_24dp);
break;
case "5": case "5":
tabToSet.setIcon(R.drawable.ic_history_white_24dp); tabToSet.setIcon(R.drawable.ic_history_white_24dp);
break;
} }
} }
@ -280,13 +328,13 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
case "0": case "0":
return new BlankFragment(); return new BlankFragment();
case "2": case "2":
SubscriptionFragment sfragment = new SubscriptionFragment(); SubscriptionFragment sFragment = new SubscriptionFragment();
sfragment.useAsFrontPage(true); sFragment.useAsFrontPage(true);
return sfragment; return sFragment;
case "3": case "3":
FeedFragment ffragment = new FeedFragment(); FeedFragment fFragment = new FeedFragment();
ffragment.useAsFrontPage(true); fFragment.useAsFrontPage(true);
return ffragment; return fFragment;
case "4": case "4":
BookmarkFragment bFragment = new BookmarkFragment(); BookmarkFragment bFragment = new BookmarkFragment();
bFragment.useAsFrontPage(true); bFragment.useAsFrontPage(true);

View File

@ -57,6 +57,8 @@ public class KioskFragment extends BaseListInfoFragment<KioskInfo> {
protected String kioskId = ""; protected String kioskId = "";
protected String kioskTranslatedName; protected String kioskTranslatedName;
private boolean mIsVisibleToUser = false;
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////
// Views // Views
//////////////////////////////////////////////////////////////////////////*/ //////////////////////////////////////////////////////////////////////////*/
@ -95,6 +97,7 @@ public class KioskFragment extends BaseListInfoFragment<KioskInfo> {
@Override @Override
public void setUserVisibleHint(boolean isVisibleToUser) { public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser); super.setUserVisibleHint(isVisibleToUser);
mIsVisibleToUser = isVisibleToUser;
if(useAsFrontPage && isVisibleToUser && activity != null) { if(useAsFrontPage && isVisibleToUser && activity != null) {
try { try {
setTitle(kioskTranslatedName); setTitle(kioskTranslatedName);
@ -167,7 +170,9 @@ public class KioskFragment extends BaseListInfoFragment<KioskInfo> {
super.handleResult(result); super.handleResult(result);
name = kioskTranslatedName; name = kioskTranslatedName;
setTitle(kioskTranslatedName); if(!useAsFrontPage) {
setTitle(kioskTranslatedName);
}
if (!result.getErrors().isEmpty()) { if (!result.getErrors().isEmpty()) {
showSnackBarError(result.getErrors(), showSnackBarError(result.getErrors(),
@ -186,4 +191,19 @@ public class KioskFragment extends BaseListInfoFragment<KioskInfo> {
, "Get next page of: " + url, 0); , "Get next page of: " + url, 0);
} }
} }
/*//////////////////////////////////////////////////////////////////////////
// Utils
//////////////////////////////////////////////////////////////////////////*/
@Override
public void setTitle(String title) {
if(!useAsFrontPage) {
super.setTitle(title);
} else {
if(mIsVisibleToUser) {
super.setTitle(title);
}
}
}
} }

View File

@ -111,7 +111,9 @@ public class StatisticsPlaylistFragment
@Override @Override
protected void initViews(View rootView, Bundle savedInstanceState) { protected void initViews(View rootView, Bundle savedInstanceState) {
super.initViews(rootView, savedInstanceState); super.initViews(rootView, savedInstanceState);
setTitle(getString(R.string.title_last_played)); if(!useAsFrontPage) {
setTitle(getString(R.string.title_last_played));
}
} }
@Override @Override