mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-24 09:00:31 +00:00
Revert "Changed the way how kiosks are handled"
This reverts commit f3da712
This commit is contained in:
parent
b441665ae2
commit
b020567e0c
@ -68,11 +68,22 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
|
|||||||
private static final String TAB_NUMBER_CHANNEL = "6";
|
private static final String TAB_NUMBER_CHANNEL = "6";
|
||||||
|
|
||||||
SharedPreferences.OnSharedPreferenceChangeListener listener = (prefs, key) -> {
|
SharedPreferences.OnSharedPreferenceChangeListener listener = (prefs, key) -> {
|
||||||
if(key.equals("saveUsedTabs")) {
|
if(key.equals("service")||key.equals("saveUsedTabs")) {
|
||||||
mainPageChanged();
|
mainPageChanged();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
// Constants
|
||||||
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
private static final int FALLBACK_SERVICE_ID = ServiceList.YouTube.getServiceId();
|
||||||
|
private static final String FALLBACK_CHANNEL_URL = "https://www.youtube.com/channel/UC-9-kyTW8ZkZNDHQJ6FgpwQ";
|
||||||
|
private static final String FALLBACK_CHANNEL_NAME = "Music";
|
||||||
|
private static final String FALLBACK_KIOSK_ID = "Trending";
|
||||||
|
private static final int KIOSK_MENU_OFFSET = 2000;
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
// Fragment's LifeCycle
|
// Fragment's LifeCycle
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
@ -125,7 +136,7 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
|
|||||||
|
|
||||||
if (tabNumber.startsWith(TAB_NUMBER_KIOSK + "\t")) {
|
if (tabNumber.startsWith(TAB_NUMBER_KIOSK + "\t")) {
|
||||||
String kiosk[] = tabNumber.split("\t");
|
String kiosk[] = tabNumber.split("\t");
|
||||||
if (kiosk.length == 3) {
|
if (kiosk.length == 2) {
|
||||||
try {
|
try {
|
||||||
setTitle(kiosk[1]);
|
setTitle(kiosk[1]);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -173,7 +184,7 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
|
|||||||
|
|
||||||
if (tabNumber.startsWith(TAB_NUMBER_KIOSK + "\t")) {
|
if (tabNumber.startsWith(TAB_NUMBER_KIOSK + "\t")) {
|
||||||
String kiosk[] = tabNumber.split("\t");
|
String kiosk[] = tabNumber.split("\t");
|
||||||
if (kiosk.length == 3) {
|
if (kiosk.length == 2) {
|
||||||
try {
|
try {
|
||||||
tabToSet.setIcon(KioskTranslator.getKioskIcons(kiosk[1], getContext()));
|
tabToSet.setIcon(KioskTranslator.getKioskIcons(kiosk[1], getContext()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -213,7 +224,27 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
|
|||||||
String save = prefs.getString("saveUsedTabs", "1\n2\n4\n");
|
String save = prefs.getString("saveUsedTabs", "1\n2\n4\n");
|
||||||
String tabsArray[] = save.trim().split("\n");
|
String tabsArray[] = save.trim().split("\n");
|
||||||
|
|
||||||
for(String tabNumber:tabsArray) { {
|
KioskList kl = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
StreamingService service = NewPipe.getService(currentServiceId);
|
||||||
|
kl = service.getKioskList();
|
||||||
|
} catch (Exception e) {
|
||||||
|
ErrorActivity.reportError(activity, e,
|
||||||
|
activity.getClass(),
|
||||||
|
null,
|
||||||
|
ErrorActivity.ErrorInfo.make(UserAction.UI_ERROR,
|
||||||
|
"none", "", R.string.app_ui_crash));
|
||||||
|
}
|
||||||
|
|
||||||
|
for(String tabNumber:tabsArray) {
|
||||||
|
if(tabNumber.equals(TAB_NUMBER_KIOSK)) {
|
||||||
|
if (kl != null) {
|
||||||
|
for(String ks : kl.getAvailableKiosks()) {
|
||||||
|
tabs.add(tabNumber+"\t"+ks);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
tabs.add(tabNumber);
|
tabs.add(tabNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -273,10 +304,10 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
|
|||||||
|
|
||||||
if(tabNumber.startsWith(TAB_NUMBER_KIOSK + "\t")) {
|
if(tabNumber.startsWith(TAB_NUMBER_KIOSK + "\t")) {
|
||||||
String kiosk[] = tabNumber.split("\t");
|
String kiosk[] = tabNumber.split("\t");
|
||||||
if(kiosk.length==3) {
|
if(kiosk.length==2) {
|
||||||
KioskFragment fragment = null;
|
KioskFragment fragment = null;
|
||||||
try {
|
try {
|
||||||
fragment = KioskFragment.getInstance(Integer.parseInt(kiosk[2]), kiosk[1]);
|
fragment = KioskFragment.getInstance(currentServiceId, kiosk[1]);
|
||||||
fragment.useAsFrontPage(true);
|
fragment.useAsFrontPage(true);
|
||||||
return fragment;
|
return fragment;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -132,7 +132,11 @@ public class ContentSettingsMain extends Fragment {
|
|||||||
|
|
||||||
|
|
||||||
private void addTab(int position) {
|
private void addTab(int position) {
|
||||||
if(position==6) {
|
if(position!=6) {
|
||||||
|
usedTabs.add(String.valueOf(position));
|
||||||
|
usedAdapter.notifyDataSetChanged();
|
||||||
|
saveChanges();
|
||||||
|
} else {
|
||||||
SelectChannelFragment selectChannelFragment = new SelectChannelFragment();
|
SelectChannelFragment selectChannelFragment = new SelectChannelFragment();
|
||||||
selectChannelFragment.setOnSelectedLisener((String url, String name, int service) -> {
|
selectChannelFragment.setOnSelectedLisener((String url, String name, int service) -> {
|
||||||
usedTabs.add(position+"\t"+url+"\t"+name+"\t"+service);
|
usedTabs.add(position+"\t"+url+"\t"+name+"\t"+service);
|
||||||
@ -140,18 +144,6 @@ public class ContentSettingsMain extends Fragment {
|
|||||||
saveChanges();
|
saveChanges();
|
||||||
});
|
});
|
||||||
selectChannelFragment.show(getFragmentManager(), "select_channel");
|
selectChannelFragment.show(getFragmentManager(), "select_channel");
|
||||||
} else if(position==1) {
|
|
||||||
SelectKioskFragment selectKioskFragment = new SelectKioskFragment();
|
|
||||||
selectKioskFragment.setOnSelectedLisener((String kioskId, int service_id) -> {
|
|
||||||
usedTabs.add(position+"\t"+kioskId+"\t"+service_id);
|
|
||||||
usedAdapter.notifyDataSetChanged();
|
|
||||||
saveChanges();
|
|
||||||
});
|
|
||||||
selectKioskFragment.show(getFragmentManager(), "select_kiosk");
|
|
||||||
} else {
|
|
||||||
usedTabs.add(String.valueOf(position));
|
|
||||||
usedAdapter.notifyDataSetChanged();
|
|
||||||
saveChanges();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,14 +212,8 @@ public class ContentSettingsMain extends Fragment {
|
|||||||
if(usedTabs.get(position).startsWith("6\t")) {
|
if(usedTabs.get(position).startsWith("6\t")) {
|
||||||
String channelInfo[] = usedTabs.get(position).split("\t");
|
String channelInfo[] = usedTabs.get(position).split("\t");
|
||||||
String channelName = "";
|
String channelName = "";
|
||||||
if (channelInfo.length == 4) channelName = channelInfo[2];
|
if(channelInfo.length==4) channelName = channelInfo[2];
|
||||||
String textToSet = allTabs[6] + ": " + channelName;
|
String textToSet = allTabs[6]+": "+channelName;
|
||||||
text.setText(textToSet);
|
|
||||||
} else if(usedTabs.get(position).startsWith("1\t")) {
|
|
||||||
String kioskInfo[] = usedTabs.get(position).split("\t");
|
|
||||||
String kioskName = "";
|
|
||||||
if (kioskInfo.length == 3) kioskName = kioskInfo[1];
|
|
||||||
String textToSet = allTabs[1] + ": " + kioskName;
|
|
||||||
text.setText(textToSet);
|
text.setText(textToSet);
|
||||||
} else {
|
} else {
|
||||||
text.setText(allTabs[Integer.parseInt(usedTabs.get(position))]);
|
text.setText(allTabs[Integer.parseInt(usedTabs.get(position))]);
|
||||||
|
Loading…
Reference in New Issue
Block a user