diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2012-08-18 17:24:08 +0200 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2012-08-18 17:24:08 +0200 |
commit | 663993afb25f8ec50678b44399c6538d1b9bd71c (patch) | |
tree | 078a6ba6f61cb435d273163e91335344bfc489ae | |
parent | b99a810a1b8cfe8bcf47396307daccccc1cea378 (diff) | |
download | AntennaPod-663993afb25f8ec50678b44399c6538d1b9bd71c.zip |
Hide 'mark all read' and 'refresh all feeds' - items when they aren't
needed
-rw-r--r-- | src/de/danoeh/antennapod/activity/MainActivity.java | 1 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/feed/Feed.java | 19 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/util/menuhandler/FeedMenuHandler.java | 5 |
3 files changed, 24 insertions, 1 deletions
diff --git a/src/de/danoeh/antennapod/activity/MainActivity.java b/src/de/danoeh/antennapod/activity/MainActivity.java index d6db17740..31907dde3 100644 --- a/src/de/danoeh/antennapod/activity/MainActivity.java +++ b/src/de/danoeh/antennapod/activity/MainActivity.java @@ -135,6 +135,7 @@ public class MainActivity extends SherlockFragmentActivity { boolean hasFeeds = !manager.getFeeds().isEmpty(); menu.findItem(R.id.opml_export).setVisible(hasFeeds); + menu.findItem(R.id.all_feed_refresh).setVisible(hasFeeds); return true; } diff --git a/src/de/danoeh/antennapod/feed/Feed.java b/src/de/danoeh/antennapod/feed/Feed.java index 4b74a62d1..057153176 100644 --- a/src/de/danoeh/antennapod/feed/Feed.java +++ b/src/de/danoeh/antennapod/feed/Feed.java @@ -80,6 +80,25 @@ public class Feed extends FeedFile { } /** + * Returns true if at least one item in the itemlist is unread.If the + * 'display only episodes' - preference is set to true, this method will + * only count items with episodes. + */ + public boolean hasNewItems() { + boolean displayOnlyEpisodes = PreferenceManager + .getDefaultSharedPreferences(PodcastApp.getInstance()) + .getBoolean(PodcastApp.PREF_DISPLAY_ONLY_EPISODES, false); + for (FeedItem item : items) { + if (!item.isRead()) { + if (!displayOnlyEpisodes || item.getMedia() != null) { + return true; + } + } + } + return false; + } + + /** * Returns the number of FeedItems. If the 'display only episodes' - * preference is set to true, this method will only count items with * episodes. diff --git a/src/de/danoeh/antennapod/util/menuhandler/FeedMenuHandler.java b/src/de/danoeh/antennapod/util/menuhandler/FeedMenuHandler.java index 6bb1478d6..0851ff062 100644 --- a/src/de/danoeh/antennapod/util/menuhandler/FeedMenuHandler.java +++ b/src/de/danoeh/antennapod/util/menuhandler/FeedMenuHandler.java @@ -33,6 +33,8 @@ public class FeedMenuHandler { public static boolean onPrepareOptionsMenu(Menu menu, Feed selectedFeed) { if (AppConfig.DEBUG) Log.d(TAG, "Preparing options menu"); + menu.findItem(R.id.mark_all_read_item).setVisible( + selectedFeed.hasNewItems()); if (selectedFeed.getPaymentLink() != null) { menu.findItem(R.id.support_item).setVisible(true); } @@ -73,7 +75,8 @@ public class FeedMenuHandler { context.startActivity(new Intent(Intent.ACTION_VIEW, uri)); break; case R.id.support_item: - new FlattrClickWorker(context, selectedFeed.getPaymentLink()).executeAsync(); + new FlattrClickWorker(context, selectedFeed.getPaymentLink()) + .executeAsync(); break; case R.id.share_link_item: ShareUtils.shareFeedlink(context, selectedFeed); |