update FeedFilterDialog

This commit is contained in:
asdoi 2020-09-03 14:15:01 +02:00
parent 0010433680
commit 7f068e95f9
1 changed files with 7 additions and 9 deletions

View File

@ -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<String> 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());
}