make summary a dynamic string

This commit is contained in:
Christian Schabesberger 2017-10-22 22:06:25 +02:00
parent c3f04ea67d
commit d1f446aae2
2 changed files with 17 additions and 9 deletions

View File

@ -40,16 +40,19 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
.putInt(getString(R.string.main_page_selected_service), service_id).apply();
defaultPreferences.edit()
.putString(getString(R.string.main_page_selectd_kiosk_id), kioskId).apply();
String summary = "";
String serviceName = "";
try {
summary += NewPipe.getService(service_id).getServiceInfo().name;
serviceName = NewPipe.getService(service_id).getServiceInfo().name;
} catch (ExtractionException e) {
onError(e);
}
summary += "/";
summary += KioskTranslator.getTranslatedKioskName(kioskId, getContext());
String kioskName = KioskTranslator.getTranslatedKioskName(kioskId,
getContext());
String summary =
String.format(getString(R.string.service_kosk_string),
serviceName,
kioskName);
mainPageContentPref.setSummary(summary);
}
@ -112,13 +115,17 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
StreamingService service = NewPipe.getService(
defaultPreferences.getInt(
getString(R.string.main_page_selected_service), 0));
String summary = "";
summary += service.getServiceInfo().name;
summary += "/";
summary += KioskTranslator.getTranslatedKioskName(
String kioskName = KioskTranslator.getTranslatedKioskName(
defaultPreferences.getString(
getString(R.string.main_page_selectd_kiosk_id), "Trending"),
getContext());
String summary =
String.format(getString(R.string.service_kosk_string),
service.getServiceInfo().name,
kioskName);
mainPagePref.setSummary(summary);
} catch (Exception e) {
onError(e);

View File

@ -290,4 +290,5 @@
<string name="trending">Trending</string>
<string name="top_50">Top 50</string>
<string name="new_and_hot">New &amp; hot</string>
<string name="service_kosk_string">%1$s/%2$s</string>
</resources>