diff options
author | Martin Fietz <Martin.Fietz@gmail.com> | 2015-12-10 16:02:08 +0100 |
---|---|---|
committer | Martin Fietz <Martin.Fietz@gmail.com> | 2015-12-10 16:02:08 +0100 |
commit | 7f729049327f783911d32d64afc32c12dded9f07 (patch) | |
tree | 88078fb4fb7927a32ceba0d13a37591b75a3ab22 /app/src/main/java/de/danoeh/antennapod/menuhandler | |
parent | c0f15653d4d986e83167402807db27e0b8a121ed (diff) | |
download | AntennaPod-7f729049327f783911d32d64afc32c12dded9f07.zip |
Just refactoring & housekeeping
Diffstat (limited to 'app/src/main/java/de/danoeh/antennapod/menuhandler')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/menuhandler/FeedMenuHandler.java | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedMenuHandler.java b/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedMenuHandler.java index 84da32a40..744ce876e 100644 --- a/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedMenuHandler.java +++ b/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedMenuHandler.java @@ -5,6 +5,7 @@ import android.content.DialogInterface; import android.content.Intent; import android.net.Uri; import android.support.v7.app.AlertDialog; +import android.text.TextUtils; import android.util.Log; import android.view.Menu; import android.view.MenuInflater; @@ -13,6 +14,7 @@ import android.widget.Toast; import java.util.ArrayList; import java.util.Arrays; +import java.util.Iterator; import java.util.List; import de.danoeh.antennapod.R; @@ -115,6 +117,13 @@ public class FeedMenuHandler { final boolean[] checkedItems = new boolean[items.length]; final List<String> hidden = new ArrayList<String>(Arrays.asList(feed.getItemFilter().getValues())); + Iterator<String> it = hidden.iterator(); + while(it.hasNext()) { + // make sure we have no empty strings in the filter list + if(TextUtils.isEmpty(it.next())) { + it.remove(); + } + } for(int i=0; i < values.length; i++) { String value = values[i]; if(hidden.contains(value)) { @@ -124,22 +133,16 @@ public class FeedMenuHandler { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(R.string.hide_episodes_title); - builder.setMultiChoiceItems(items, checkedItems, new DialogInterface.OnMultiChoiceClickListener() { - @Override - public void onClick(DialogInterface dialog, int which, boolean isChecked) { - if (isChecked) { - hidden.add(values[which]); - } else { - hidden.remove(values[which]); - } + builder.setMultiChoiceItems(items, checkedItems, (dialog, which, isChecked) -> { + if (isChecked) { + hidden.add(values[which]); + } else { + hidden.remove(values[which]); } }); - builder.setPositiveButton(R.string.confirm_label, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - feed.setHiddenItemProperties(hidden.toArray(new String[hidden.size()])); - DBWriter.setFeedItemsFilter(feed.getId(), hidden); - } + builder.setPositiveButton(R.string.confirm_label, (dialog, which) -> { + feed.setHiddenItemProperties(hidden.toArray(new String[hidden.size()])); + DBWriter.setFeedItemsFilter(feed.getId(), hidden); }); builder.setNegativeButton(R.string.cancel_label, null); builder.create().show(); |