From 337926f9869b8ef4f754af6eaf04d0d4a94465a5 Mon Sep 17 00:00:00 2001 From: dosiecki Date: Mon, 27 Oct 2014 00:43:43 -0700 Subject: [PATCH] Fix re-use of folder list on rotation. --- .../src/com/newsblur/database/FolderListAdapter.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/clients/android/NewsBlur/src/com/newsblur/database/FolderListAdapter.java b/clients/android/NewsBlur/src/com/newsblur/database/FolderListAdapter.java index 628c033aa..ba693afe1 100644 --- a/clients/android/NewsBlur/src/com/newsblur/database/FolderListAdapter.java +++ b/clients/android/NewsBlur/src/com/newsblur/database/FolderListAdapter.java @@ -285,12 +285,14 @@ public class FolderListAdapter extends BaseExpandableListAdapter { socialFeedColumnMap.put(cursor.getColumnIndexOrThrow(DatabaseConstants.SOCIAL_FEED_NEUTRAL_COUNT), R.id.row_socialsumneu); socialFeedColumnMap.put(cursor.getColumnIndexOrThrow(DatabaseConstants.SOCIAL_FEED_POSITIVE_COUNT), R.id.row_socialsumpos); } - recountFeeds(); notifyDataSetChanged(); } - public void setFolderFeedMapCursor(Cursor cursor) { + public synchronized void setFolderFeedMapCursor(Cursor cursor) { + if (cursor.getCount() < 1) return; this.folderFeedMap = new TreeMap>(); + // some newer frameworks like to re-use cursors, so we cannot assume a starting index + cursor.moveToPosition(-1); while (cursor.moveToNext()) { String folderName = getStr(cursor, DatabaseConstants.FEED_FOLDER_FOLDER_NAME); String feedId = getStr(cursor, DatabaseConstants.FEED_FOLDER_FEED_ID); @@ -301,7 +303,7 @@ public class FolderListAdapter extends BaseExpandableListAdapter { notifyDataSetChanged(); } - public void setFeedCursor(Cursor cursor) { + public synchronized void setFeedCursor(Cursor cursor) { this.feedCursor = cursor; if (feedColumnMap == null) { feedColumnMap = new HashMap(); @@ -310,6 +312,7 @@ public class FolderListAdapter extends BaseExpandableListAdapter { feedColumnMap.put(cursor.getColumnIndexOrThrow(DatabaseConstants.FEED_NEUTRAL_COUNT), R.id.row_feedneutral); feedColumnMap.put(cursor.getColumnIndexOrThrow(DatabaseConstants.FEED_POSITIVE_COUNT), R.id.row_feedpositive); } + recountFeeds(); notifyDataSetChanged(); }