mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-27 02:20: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();
|
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() {
|
||||||
@ -137,19 +181,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,13 +320,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);
|
||||||
|
@ -59,6 +59,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
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
@ -97,6 +99,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);
|
||||||
@ -163,7 +166,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(),
|
||||||
@ -182,4 +187,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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user