mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-25 09:30:32 +00:00
Fixed icons and tab titles
This commit is contained in:
parent
27f64b8bc2
commit
dc1896e3f5
@ -116,6 +116,50 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
|
||||
adapter.notifyDataSetChanged();
|
||||
viewPager.setOffscreenPageLimit(adapter.getCount());
|
||||
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() {
|
||||
@ -137,19 +181,23 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
|
||||
}
|
||||
} else if (tabNumber.startsWith("6\t")) {
|
||||
tabToSet.setIcon(R.drawable.ic_channel_white_24dp);
|
||||
|
||||
} else {
|
||||
switch (tabNumber) {
|
||||
case "0":
|
||||
tabToSet.setIcon(R.drawable.ic_whatshot_white_24dp);
|
||||
break;
|
||||
case "2":
|
||||
tabToSet.setIcon(R.drawable.ic_channel_white_24dp);
|
||||
break;
|
||||
case "3":
|
||||
tabToSet.setIcon(R.drawable.ic_rss_feed_white_24dp);
|
||||
break;
|
||||
case "4":
|
||||
tabToSet.setIcon(R.drawable.ic_bookmark_white_24dp);
|
||||
break;
|
||||
case "5":
|
||||
tabToSet.setIcon(R.drawable.ic_history_white_24dp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -272,13 +320,13 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
|
||||
case "0":
|
||||
return new BlankFragment();
|
||||
case "2":
|
||||
SubscriptionFragment sfragment = new SubscriptionFragment();
|
||||
sfragment.useAsFrontPage(true);
|
||||
return sfragment;
|
||||
SubscriptionFragment sFragment = new SubscriptionFragment();
|
||||
sFragment.useAsFrontPage(true);
|
||||
return sFragment;
|
||||
case "3":
|
||||
FeedFragment ffragment = new FeedFragment();
|
||||
ffragment.useAsFrontPage(true);
|
||||
return ffragment;
|
||||
FeedFragment fFragment = new FeedFragment();
|
||||
fFragment.useAsFrontPage(true);
|
||||
return fFragment;
|
||||
case "4":
|
||||
BookmarkFragment bFragment = new BookmarkFragment();
|
||||
bFragment.useAsFrontPage(true);
|
||||
|
@ -59,6 +59,8 @@ public class KioskFragment extends BaseListInfoFragment<KioskInfo> {
|
||||
protected String kioskId = "";
|
||||
protected String kioskTranslatedName;
|
||||
|
||||
private boolean mIsVisibleToUser = false;
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// Views
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
@ -97,6 +99,7 @@ public class KioskFragment extends BaseListInfoFragment<KioskInfo> {
|
||||
@Override
|
||||
public void setUserVisibleHint(boolean isVisibleToUser) {
|
||||
super.setUserVisibleHint(isVisibleToUser);
|
||||
mIsVisibleToUser = isVisibleToUser;
|
||||
if(useAsFrontPage && isVisibleToUser && activity != null) {
|
||||
try {
|
||||
setTitle(kioskTranslatedName);
|
||||
@ -163,7 +166,9 @@ public class KioskFragment extends BaseListInfoFragment<KioskInfo> {
|
||||
super.handleResult(result);
|
||||
|
||||
name = kioskTranslatedName;
|
||||
setTitle(kioskTranslatedName);
|
||||
if(!useAsFrontPage) {
|
||||
setTitle(kioskTranslatedName);
|
||||
}
|
||||
|
||||
if (!result.getErrors().isEmpty()) {
|
||||
showSnackBarError(result.getErrors(),
|
||||
@ -182,4 +187,19 @@ public class KioskFragment extends BaseListInfoFragment<KioskInfo> {
|
||||
, "Get next page of: " + url, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// Utils
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
@Override
|
||||
public void setTitle(String title) {
|
||||
if(!useAsFrontPage) {
|
||||
super.setTitle(title);
|
||||
} else {
|
||||
if(mIsVisibleToUser) {
|
||||
super.setTitle(title);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +111,9 @@ public class StatisticsPlaylistFragment
|
||||
@Override
|
||||
protected void initViews(View rootView, Bundle savedInstanceState) {
|
||||
super.initViews(rootView, savedInstanceState);
|
||||
setTitle(getString(R.string.title_last_played));
|
||||
if(!useAsFrontPage) {
|
||||
setTitle(getString(R.string.title_last_played));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user