From 16afff4dfcb6adcedb021d6753feb660a1540e5c Mon Sep 17 00:00:00 2001 From: cketti Date: Sun, 18 Mar 2012 22:09:52 +0100 Subject: [PATCH] Notify the adapter from runOnUiThread() instead of using Handler --- src/com/fsck/k9/activity/ChooseFolder.java | 31 ++++++++-------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/src/com/fsck/k9/activity/ChooseFolder.java b/src/com/fsck/k9/activity/ChooseFolder.java index 170f64358..1cfdfa976 100644 --- a/src/com/fsck/k9/activity/ChooseFolder.java +++ b/src/com/fsck/k9/activity/ChooseFolder.java @@ -135,9 +135,8 @@ public class ChooseFolder extends K9ListActivity { } class ChooseFolderHandler extends Handler { - private static final int MSG_PROGRESS = 2; - private static final int MSG_DATA_CHANGED = 3; - private static final int MSG_SET_SELECTED_FOLDER = 4; + private static final int MSG_PROGRESS = 1; + private static final int MSG_SET_SELECTED_FOLDER = 2; @Override public void handleMessage(android.os.Message msg) { @@ -146,17 +145,6 @@ public class ChooseFolder extends K9ListActivity { setProgressBarIndeterminateVisibility(msg.arg1 != 0); break; } - case MSG_DATA_CHANGED: { - mAdapter.notifyDataSetChanged(); - - /* - * Only enable the text filter after the list has been - * populated to avoid possible race conditions because our - * FolderListFilter isn't really thread-safe. - */ - getListView().setTextFilterEnabled(true); - break; - } case MSG_SET_SELECTED_FOLDER: { getListView().setSelection(msg.arg1); break; @@ -177,10 +165,6 @@ public class ChooseFolder extends K9ListActivity { msg.arg1 = position; sendMessage(msg); } - - public void dataChanged() { - sendEmptyMessage(MSG_DATA_CHANGED); - } } @Override @@ -409,12 +393,19 @@ public class ChooseFolder extends K9ListActivity { for (String folderName: folderList) { mAdapter.add(folderName); } + + mAdapter.notifyDataSetChanged(); + + /* + * Only enable the text filter after the list has been + * populated to avoid possible race conditions because our + * FolderListFilter isn't really thread-safe. + */ + getListView().setTextFilterEnabled(true); } }); } - mHandler.dataChanged(); - if (selectedFolder != -1) { mHandler.setSelectedFolder(selectedFolder); }