diff options
author | recalculated <recalculated@users.noreply.github.com> | 2016-01-23 20:16:53 -0600 |
---|---|---|
committer | recalculated <recalculated@users.noreply.github.com> | 2016-01-23 20:25:08 -0600 |
commit | 9ef3c99899196538baa446db869c2ac23c15cb99 (patch) | |
tree | e01d5b88525bad828aae96208e4389f7cb3c6f99 /app | |
parent | 7e9e3bb9468c4829bac94fc5d3f8165d86d02bdb (diff) | |
download | AntennaPod-9ef3c99899196538baa446db869c2ac23c15cb99.zip |
Use positive/reverse filtering
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/menuhandler/FeedMenuHandler.java | 27 | ||||
-rw-r--r-- | app/src/main/res/menu/feedlist.xml | 4 |
2 files changed, 15 insertions, 16 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 2d6d4cac1..830e9d419 100644 --- a/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedMenuHandler.java +++ b/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedMenuHandler.java @@ -68,8 +68,8 @@ public class FeedMenuHandler { case R.id.refresh_complete_item: DBTasks.refreshCompleteFeed(context, selectedFeed); break; - case R.id.hide_items: - showHideDialog(context, selectedFeed); + case R.id.filter_items: + showFilterDialog(context, selectedFeed); break; case R.id.mark_all_read_item: ConfirmationDialog conDialog = new ConfirmationDialog(context, @@ -110,14 +110,13 @@ public class FeedMenuHandler { return true; } - private static void showHideDialog(final Context context, final Feed feed) { - - final String[] items = context.getResources().getStringArray(R.array.episode_hide_options); - final String[] values = context.getResources().getStringArray(R.array.episode_hide_values); + private static void showFilterDialog(final Context context, final Feed feed) { + final String[] items = context.getResources().getStringArray(R.array.episode_filter_options); + final String[] values = context.getResources().getStringArray(R.array.episode_filter_values); final boolean[] checkedItems = new boolean[items.length]; - final Set<String> hidden = new HashSet<String>(Arrays.asList(feed.getItemFilter().getValues())); - Iterator<String> it = hidden.iterator(); + final Set<String> filter = new HashSet<>(Arrays.asList(feed.getItemFilter().getValues())); + Iterator<String> it = filter.iterator(); while(it.hasNext()) { // make sure we have no empty strings in the filter list if(TextUtils.isEmpty(it.next())) { @@ -126,23 +125,23 @@ public class FeedMenuHandler { } for(int i=0; i < values.length; i++) { String value = values[i]; - if(hidden.contains(value)) { + if(filter.contains(value)) { checkedItems[i] = true; } } AlertDialog.Builder builder = new AlertDialog.Builder(context); - builder.setTitle(R.string.hide_episodes_title); + builder.setTitle(R.string.filter); builder.setMultiChoiceItems(items, checkedItems, (dialog, which, isChecked) -> { if (isChecked) { - hidden.add(values[which]); + filter.add(values[which]); } else { - hidden.remove(values[which]); + filter.remove(values[which]); } }); builder.setPositiveButton(R.string.confirm_label, (dialog, which) -> { - feed.setHiddenItemProperties(hidden.toArray(new String[hidden.size()])); - DBWriter.setFeedItemsFilter(feed.getId(), hidden); + feed.setItemFilter(filter.toArray(new String[filter.size()])); + DBWriter.setFeedItemsFilter(feed.getId(), filter); }); builder.setNegativeButton(R.string.cancel_label, null); builder.create().show(); diff --git a/app/src/main/res/menu/feedlist.xml b/app/src/main/res/menu/feedlist.xml index 54b90f5c6..ed03c08d6 100644 --- a/app/src/main/res/menu/feedlist.xml +++ b/app/src/main/res/menu/feedlist.xml @@ -3,10 +3,10 @@ xmlns:custom="http://schemas.android.com/apk/res-auto"> <item - android:id="@+id/hide_items" + android:id="@+id/filter_items" android:icon="?attr/ic_filter" android:menuCategory="container" - android:title="@string/hide_episodes_title" + android:title="@string/filter" custom:showAsAction="always"> </item> <item |