From a66580bfc62630076abbcb25674016d1f930d6dc Mon Sep 17 00:00:00 2001 From: daniel oeh Date: Mon, 25 Jun 2012 13:22:26 +0200 Subject: [PATCH] Improved performance when marking all feeditems of a feed as read --- src/de/podfetcher/feed/FeedManager.java | 12 ++++++++++++ src/de/podfetcher/fragment/ItemlistFragment.java | 1 + src/de/podfetcher/util/FeedMenuHandler.java | 5 +---- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/de/podfetcher/feed/FeedManager.java b/src/de/podfetcher/feed/FeedManager.java index 417d4a4cf..b721c1746 100644 --- a/src/de/podfetcher/feed/FeedManager.java +++ b/src/de/podfetcher/feed/FeedManager.java @@ -145,6 +145,18 @@ public class FeedManager { unreadItems.add(item); } } + + /** + * Sets the 'read' attribute of all FeedItems of a specific feed to true + * @param context + */ + public void markFeedRead(Context context, Feed feed) { + for (FeedItem item : feed.getItems()) { + if (unreadItems.contains(item)) { + markItemRead(context, item, true); + } + } + } public void refreshAllFeeds(Context context) { Log.d(TAG, "Refreshing all feeds."); diff --git a/src/de/podfetcher/fragment/ItemlistFragment.java b/src/de/podfetcher/fragment/ItemlistFragment.java index 9e4cefeb8..6cc14548a 100644 --- a/src/de/podfetcher/fragment/ItemlistFragment.java +++ b/src/de/podfetcher/fragment/ItemlistFragment.java @@ -85,6 +85,7 @@ public class ItemlistFragment extends SherlockListFragment { @Override public void onResume() { super.onResume(); + fila.notifyDataSetChanged(); IntentFilter filter = new IntentFilter(); filter.addAction(DownloadService.ACTION_DOWNLOAD_HANDLED); filter.addAction(DownloadRequester.ACTION_DOWNLOAD_QUEUED); diff --git a/src/de/podfetcher/util/FeedMenuHandler.java b/src/de/podfetcher/util/FeedMenuHandler.java index 140b895ff..84f6d898f 100644 --- a/src/de/podfetcher/util/FeedMenuHandler.java +++ b/src/de/podfetcher/util/FeedMenuHandler.java @@ -31,10 +31,7 @@ public class FeedMenuHandler { FeedManager manager = FeedManager.getInstance(); switch (item.getItemId()) { case R.id.mark_all_read_item: - for (FeedItem feeditem : selectedFeed.getItems()) { - manager.markItemRead(context, feeditem, true); - } - + manager.markFeedRead(context, selectedFeed); break; default: return false;