Search in sources :

Example 1 with PreferenceListDialog

use of de.danoeh.antennapod.fragment.preferences.dialog.PreferenceListDialog in project AntennaPod by AntennaPod.

the class FeedMultiSelectActionHandler method autoDeleteEpisodesPrefHandler.

private void autoDeleteEpisodesPrefHandler() {
    PreferenceListDialog preferenceListDialog = new PreferenceListDialog(activity, "Auto delete episodes");
    String[] items = activity.getResources().getStringArray(R.array.spnAutoDeleteItems);
    String[] values = activity.getResources().getStringArray(R.array.spnAutoDeleteValues);
    preferenceListDialog.openDialog(items);
    preferenceListDialog.setOnPreferenceChangedListener(which -> {
        FeedPreferences.AutoDeleteAction autoDeleteAction = null;
        switch(values[which]) {
            case "global":
                autoDeleteAction = FeedPreferences.AutoDeleteAction.GLOBAL;
                break;
            case "always":
                autoDeleteAction = FeedPreferences.AutoDeleteAction.YES;
                break;
            case "never":
                autoDeleteAction = FeedPreferences.AutoDeleteAction.NO;
                break;
            default:
        }
        FeedPreferences.AutoDeleteAction finalAutoDeleteAction = autoDeleteAction;
        saveFeedPreferences(feedPreferences -> {
            feedPreferences.setAutoDeleteAction(finalAutoDeleteAction);
        });
    });
}
Also used : FeedPreferences(de.danoeh.antennapod.model.feed.FeedPreferences) PreferenceListDialog(de.danoeh.antennapod.fragment.preferences.dialog.PreferenceListDialog)

Aggregations

PreferenceListDialog (de.danoeh.antennapod.fragment.preferences.dialog.PreferenceListDialog)1 FeedPreferences (de.danoeh.antennapod.model.feed.FeedPreferences)1