Merge pull request #2141 from mfietz/2079-has-media-filter

Add "has media" filter
This commit is contained in:
Martin Fietz 2016-10-08 09:47:30 +02:00 committed by GitHub
commit fcf888237f
5 changed files with 27 additions and 0 deletions

View File

@ -225,6 +225,9 @@ public class EpisodesApplyActionFragment extends Fragment {
checkQueued(false); checkQueued(false);
resId = R.string.selected_not_queued_label; resId = R.string.selected_not_queued_label;
break; break;
case R.id.check_has_media:
checkWithMedia();
resId = R.string.selected_has_media_label;
case R.id.sort_title_a_z: case R.id.sort_title_a_z:
sortByTitle(false); sortByTitle(false);
return true; return true;
@ -357,6 +360,17 @@ public class EpisodesApplyActionFragment extends Fragment {
refreshCheckboxes(); refreshCheckboxes();
} }
private void checkWithMedia() {
for (FeedItem episode : episodes) {
if(episode.hasMedia()) {
checkedIds.add(episode.getId());
} else {
checkedIds.remove(episode.getId());
}
}
refreshCheckboxes();
}
private void refreshTitles() { private void refreshTitles() {
titles.clear(); titles.clear();
for(FeedItem episode : episodes) { for(FeedItem episode : episodes) {

View File

@ -46,6 +46,8 @@
android:title="@string/queued_label"/> android:title="@string/queued_label"/>
<item android:id="@+id/check_not_queued" <item android:id="@+id/check_not_queued"
android:title="@string/not_queued_label"/> android:title="@string/not_queued_label"/>
<item android:id="@+id/check_has_media"
android:title="@string/has_media"/>
</menu> </menu>
</item> </item>

View File

@ -18,6 +18,7 @@ public class FeedItemFilter {
private boolean showNotQueued = false; private boolean showNotQueued = false;
private boolean showDownloaded = false; private boolean showDownloaded = false;
private boolean showNotDownloaded = false; private boolean showNotDownloaded = false;
private boolean showHasMedia = false;
public FeedItemFilter(String properties) { public FeedItemFilter(String properties) {
this(TextUtils.split(properties, ",")); this(TextUtils.split(properties, ","));
@ -49,6 +50,9 @@ public class FeedItemFilter {
case "not_downloaded": case "not_downloaded":
showNotDownloaded = true; showNotDownloaded = true;
break; break;
case "has_media":
showHasMedia = true;
break;
} }
} }
} }
@ -82,6 +86,8 @@ public class FeedItemFilter {
if (showDownloaded && !downloaded) continue; if (showDownloaded && !downloaded) continue;
if (showNotDownloaded && downloaded) continue; if (showNotDownloaded && downloaded) continue;
if (showHasMedia && !item.hasMedia()) continue;
// If the item reaches here, it meets all criteria // If the item reaches here, it meets all criteria
result.add(item); result.add(item);
} }

View File

@ -185,6 +185,7 @@
<item>@string/hide_not_queued_episodes_label</item> <item>@string/hide_not_queued_episodes_label</item>
<item>@string/hide_downloaded_episodes_label</item> <item>@string/hide_downloaded_episodes_label</item>
<item>@string/hide_not_downloaded_episodes_label</item> <item>@string/hide_not_downloaded_episodes_label</item>
<item>@string/hide_has_media_label</item>
</string-array> </string-array>
<string-array name="episode_filter_values"> <string-array name="episode_filter_values">
@ -195,6 +196,7 @@
<item>not_queued</item> <item>not_queued</item>
<item>downloaded</item> <item>downloaded</item>
<item>not_downloaded</item> <item>not_downloaded</item>
<item>has_media</item>
</string-array> </string-array>
<string-array name="image_cache_size_options"> <string-array name="image_cache_size_options">

View File

@ -131,6 +131,7 @@
<string name="hide_not_queued_episodes_label">Not queued</string> <string name="hide_not_queued_episodes_label">Not queued</string>
<string name="hide_downloaded_episodes_label">Downloaded</string> <string name="hide_downloaded_episodes_label">Downloaded</string>
<string name="hide_not_downloaded_episodes_label">Not downloaded</string> <string name="hide_not_downloaded_episodes_label">Not downloaded</string>
<string name="hide_has_media_label">Has media</string>
<string name="filtered_label">Filtered</string> <string name="filtered_label">Filtered</string>
<string name="refresh_failed_msg">{fa-exclamation-circle} Last Refresh failed</string> <string name="refresh_failed_msg">{fa-exclamation-circle} Last Refresh failed</string>
<string name="open_podcast">Open Podcast</string> <string name="open_podcast">Open Podcast</string>
@ -587,6 +588,8 @@
<string name="selected_queued_label">Selected queued Episodes</string> <string name="selected_queued_label">Selected queued Episodes</string>
<string name="not_queued_label">Not queued</string> <string name="not_queued_label">Not queued</string>
<string name="selected_not_queued_label">Selected not queued Episodes</string> <string name="selected_not_queued_label">Selected not queued Episodes</string>
<string name="has_media">Has media</string>
<string name="selected_has_media_label">Selected episodes with media</string>
<!-- Sort --> <!-- Sort -->
<string name="sort_title_a_z">Title (A \u2192 Z)</string> <string name="sort_title_a_z">Title (A \u2192 Z)</string>