From 60ea4c6ce71b0f97af18a60cf85f6387fad48fb6 Mon Sep 17 00:00:00 2001 From: Marcus Wolschon Date: Tue, 18 Jan 2011 15:34:41 +0000 Subject: [PATCH] Update issue 2479 possible fix for "The content of the adapter has changed but ListView did not receive a notification." --- src/com/fsck/k9/activity/ChooseFolder.java | 70 ++++++++++++---------- 1 file changed, 40 insertions(+), 30 deletions(-) diff --git a/src/com/fsck/k9/activity/ChooseFolder.java b/src/com/fsck/k9/activity/ChooseFolder.java index 272825088..0dd0d1ffd 100644 --- a/src/com/fsck/k9/activity/ChooseFolder.java +++ b/src/com/fsck/k9/activity/ChooseFolder.java @@ -341,39 +341,49 @@ public class ChooseFolder extends K9ListActivity } }); mAdapter.setNotifyOnChange(false); - mAdapter.clear(); int selectedFolder = -1; - int position = 0; - for (String name : localFolders) - { - if (K9.INBOX.equalsIgnoreCase(name)) - { - mAdapter.add(getString(R.string.special_mailbox_name_inbox)); - heldInbox = name; - } - else if (!K9.ERROR_FOLDER_NAME.equals(name)) - { - mAdapter.add(name); - } + try { + mAdapter.clear(); + int position = 0; + for (String name : localFolders) + { + if (K9.INBOX.equalsIgnoreCase(name)) + { + mAdapter.add(getString(R.string.special_mailbox_name_inbox)); + heldInbox = name; + } + else if (!K9.ERROR_FOLDER_NAME.equals(name)) + { + mAdapter.add(name); + } - if (mSelectFolder != null) - { - /* - * Never select EXTRA_CUR_FOLDER (mFolder) if EXTRA_SEL_FOLDER - * (mSelectedFolder) was provided. - */ + if (mSelectFolder != null) + { + /* + * Never select EXTRA_CUR_FOLDER (mFolder) if EXTRA_SEL_FOLDER + * (mSelectedFolder) was provided. + */ - if (name.equals(mSelectFolder)) - { - selectedFolder = position; - } - } - else if (name.equals(mFolder) || - (K9.INBOX.equalsIgnoreCase(mFolder) && K9.INBOX.equalsIgnoreCase(name))) - { - selectedFolder = position; - } - position++; + if (name.equals(mSelectFolder)) + { + selectedFolder = position; + } + } + else if (name.equals(mFolder) || + (K9.INBOX.equalsIgnoreCase(mFolder) && K9.INBOX.equalsIgnoreCase(name))) + { + selectedFolder = position; + } + position++; + } + } finally { + mAdapter.setNotifyOnChange(true); + runOnUiThread(new Runnable() { + public void run() { + // runOnUiThread( + mAdapter.notifyDataSetChanged(); + } + }); } mHandler.dataChanged();