From 709f74207ad024d9340307d6b5a745ef59feabd6 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Tue, 17 Jan 2012 20:22:02 -0800 Subject: [PATCH] Use the broadcast refresh mechanism for sync finished callbacks in TLA and TVA. This gives better consistency and fewer crashes." --- .../com/todoroo/astrid/actfm/TagViewActivity.java | 11 ++++++++--- .../todoroo/astrid/activity/TaskListActivity.java | 15 ++++++++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/TagViewActivity.java b/astrid/plugin-src/com/todoroo/astrid/actfm/TagViewActivity.java index 3a822331a..b1b75704d 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/TagViewActivity.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/TagViewActivity.java @@ -254,9 +254,7 @@ public class TagViewActivity extends TaskListActivity { R.id.progressBar, new Runnable() { @Override public void run() { - setUpMembersGallery(); - loadTaskListContent(true); - ((TextView)taskListView.findViewById(android.R.id.empty)).setText(R.string.TLA_no_items); + ContextManager.getContext().sendBroadcast(new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH)); } })); Preferences.setLong(LAST_FETCH_KEY + tagData.getId(), DateUtilities.now()); @@ -467,4 +465,11 @@ public class TagViewActivity extends TaskListActivity { return super.onOptionsItemSelected(item); } + @Override + protected void refresh() { + setUpMembersGallery(); + loadTaskListContent(true); + ((TextView)taskListView.findViewById(android.R.id.empty)).setText(R.string.TLA_no_items); + } + } diff --git a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java index 27458c826..154d63449 100644 --- a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java @@ -686,13 +686,22 @@ public class TaskListActivity extends ListFragment implements OnScrollListener, getActivity().runOnUiThread(new Runnable() { @Override public void run() { - taskAdapter.flushCaches(); - loadTaskListContent(true); + refresh(); } }); } } + + /** + * Called by the RefreshReceiver when the task list receives a refresh + * broadcast. Subclasses should override this. + */ + protected void refresh() { + taskAdapter.flushCaches(); + loadTaskListContent(true); + } + /** * Receiver which receives sync provider intents * @@ -1178,7 +1187,7 @@ public class TaskListActivity extends ListFragment implements OnScrollListener, R.id.progressBar, new Runnable() { @Override public void run() { - loadTaskListContent(true); + ContextManager.getContext().sendBroadcast(new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH)); } })); Preferences.setLong(PREF_LAST_AUTO_SYNC, DateUtilities.now());