From 7f068e95f9383e74543ff1480be1811d1d6b7c6a Mon Sep 17 00:00:00 2001 From: asdoi Date: Thu, 3 Sep 2020 14:15:01 +0200 Subject: [PATCH] update FeedFilterDialog --- .../antennapod/dialog/FeedFilterDialog.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/FeedFilterDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/FeedFilterDialog.java index 7d1fe4026..3b0e2d04b 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/FeedFilterDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/FeedFilterDialog.java @@ -6,6 +6,9 @@ import androidx.appcompat.app.AlertDialog; import org.greenrobot.eventbus.EventBus; +import java.util.Arrays; +import java.util.List; + import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.event.UnreadItemsUpdateEvent; import de.danoeh.antennapod.core.preferences.UserPreferences; @@ -16,20 +19,15 @@ public class FeedFilterDialog { dialog.setTitle(context.getString(R.string.pref_filter_feed_title)); dialog.setNegativeButton(android.R.string.cancel, (d, listener) -> d.dismiss()); - int selectedIndexTemp = 0; int selected = UserPreferences.getFeedFilter(); - String[] entryValues = context.getResources().getStringArray(R.array.nav_drawer_feed_filter_values); - for (int i = 0; i < entryValues.length; i++) { - if (Integer.parseInt(entryValues[i]) == selected) { - selectedIndexTemp = i; - } - } + List entryValues = + Arrays.asList(context.getResources().getStringArray(R.array.nav_drawer_feed_filter_values)); + final int selectedIndex = entryValues.indexOf("" + selected); - final int selectedIndex = selectedIndexTemp; String[] items = context.getResources().getStringArray(R.array.nav_drawer_feed_filter_options); dialog.setSingleChoiceItems(items, selectedIndex, (d, which) -> { if (selectedIndex != which) { - UserPreferences.setFeedFilter(entryValues[which]); + UserPreferences.setFeedFilter(entryValues.get(which)); //Update subscriptions EventBus.getDefault().post(new UnreadItemsUpdateEvent()); }