1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-24 16:48:50 -05:00

Notify the adapter from runOnUiThread() instead of using Handler

This commit is contained in:
cketti 2012-03-18 22:09:52 +01:00
parent 4f2412eacd
commit 16afff4dfc

View File

@ -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);
}