From 7fcc07805a20d0eb350e3efd77b3ca18777243c1 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Mon, 9 Oct 2017 14:34:10 +0200 Subject: [PATCH] make kiosk selector signle service again --- .../org/schabi/newpipe/fragments/MainFragment.java | 12 +++++++----- .../schabi/newpipe/settings/SelectKioskFragment.java | 12 +++++++++--- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java index 4ba648402..48f2d150e 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java @@ -185,13 +185,17 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte private Fragment getMainPageFramgent() { try { - final String set_main_page = PreferenceManager.getDefaultSharedPreferences(getActivity()) - .getString(getString(R.string.main_page_content_key), + SharedPreferences preferences = + PreferenceManager.getDefaultSharedPreferences(getActivity()); + final String set_main_page = preferences.getString(getString(R.string.main_page_content_key), getString(R.string.main_page_selectd_kiosk_id)); if(set_main_page.equals(getString(R.string.blank_page_key))) { return new BlankFragment(); } else if(set_main_page.equals(getString(R.string.kiosk_page_key))) { - KioskFragment fragment = KioskFragment.getInstance(currentServiceId); + int serviceId = preferences.getInt(getString(R.string.main_page_selected_service), 0); + String kioskId = preferences.getString(getString(R.string.main_page_selectd_kiosk_id), "Trending"); + KioskFragment fragment = KioskFragment.getInstance(serviceId, kioskId + ); fragment.useAsFrontPage(true); return fragment; } else if(set_main_page.equals(getString(R.string.feed_page_key))) { @@ -199,8 +203,6 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte fragment.useAsFrontPage(true); return fragment; } else if(set_main_page.equals(getString(R.string.channel_page_key))) { - SharedPreferences preferences = - PreferenceManager.getDefaultSharedPreferences(getActivity()); int serviceId = preferences.getInt(getString(R.string.main_page_selected_service), 0); String url = preferences.getString(getString(R.string.main_page_selected_channel_url), "https://www.youtube.com/channel/UC-9-kyTW8ZkZNDHQJ6FgpwQ"); diff --git a/app/src/main/java/org/schabi/newpipe/settings/SelectKioskFragment.java b/app/src/main/java/org/schabi/newpipe/settings/SelectKioskFragment.java index 6e7ba191e..204b35905 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/SelectKioskFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/SelectKioskFragment.java @@ -117,25 +117,31 @@ public class SelectKioskFragment extends DialogFragment { int serviceId; String kioskId; String kioskName; - }; + } private List kioskList = new Vector<>(); public SelectKioskAdapter() throws Exception { + for(StreamingService service : NewPipe.getServices()) { for(String kioskId : service.getKioskList().getAvailableKisoks()) { + String name = service.getServiceInfo().name; + name += "/"; + name += KioskTranslator.getTranslatedKioskName(kioskId, getContext()); kioskList.add(new Entry( ServiceIconMapper.getIconResource(service.getServiceId()), service.getServiceId(), kioskId, - KioskTranslator.getTranslatedKioskName(kioskId, getContext()))); + name)); } } } public int getItemCount() { - return kioskList.size(); + //todo: uncommend this line on multyservice support + //return kioskList.size(); + return 1; } public SelectKioskItemHolder onCreateViewHolder(ViewGroup parent, int type) {