From 7451ca813e749ca2082fc36255174fb304653ff6 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Wed, 11 Apr 2012 14:52:34 -0700 Subject: [PATCH] Don't do a full broadcast refresh when autosyncing --- .../todoroo/astrid/actfm/TagViewFragment.java | 5 +++- .../astrid/gtasks/GtasksListFragment.java | 24 +++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/TagViewFragment.java b/astrid/plugin-src/com/todoroo/astrid/actfm/TagViewFragment.java index 38b05bce4..b22c79175 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/TagViewFragment.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/TagViewFragment.java @@ -281,7 +281,10 @@ public class TagViewFragment extends TaskListFragment { R.id.progressBar, new Runnable() { @Override public void run() { - ContextManager.getContext().sendBroadcast(new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH)); + if (manual) + ContextManager.getContext().sendBroadcast(new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH)); + else + refresh(); ((TextView)taskListView.findViewById(android.R.id.empty)).setText(R.string.TLA_no_items); } })); diff --git a/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksListFragment.java b/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksListFragment.java index 0e13f2a94..f74632911 100644 --- a/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksListFragment.java +++ b/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksListFragment.java @@ -6,16 +6,20 @@ import android.content.Intent; import android.os.Bundle; import android.support.v4.view.Menu; import android.view.MenuInflater; +import android.widget.TextView; import com.timsu.astrid.R; import com.todoroo.andlib.data.Property; import com.todoroo.andlib.data.TodorooCursor; import com.todoroo.andlib.service.Autowired; +import com.todoroo.andlib.service.ContextManager; import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.andlib.utility.DialogUtilities; +import com.todoroo.astrid.api.AstridApiConstants; import com.todoroo.astrid.dao.StoreObjectDao; import com.todoroo.astrid.data.StoreObject; import com.todoroo.astrid.data.Task; +import com.todoroo.astrid.helper.ProgressBarSyncResultCallback; import com.todoroo.astrid.service.SyncV2Service; import com.todoroo.astrid.service.ThemeService; import com.todoroo.astrid.subtasks.OrderedListFragmentHelper; @@ -74,10 +78,26 @@ public class GtasksListFragment extends SubtasksListFragment { if (!isCurrentTaskListFragment()) return; if (list != null && DateUtilities.now() - list.getValue(GtasksList.LAST_SYNC) > DateUtilities.ONE_HOUR) { - syncService.synchronizeList(list, false, syncActionHelper.syncResultCallback); + refreshData(false); } } + private void refreshData(final boolean manual) { + ((TextView)getView().findViewById(android.R.id.empty)).setText(R.string.DLG_loading); + + syncService.synchronizeList(list, manual, new ProgressBarSyncResultCallback(getActivity(), this, + R.id.progressBar, new Runnable() { + @Override + public void run() { + if (manual) + ContextManager.getContext().sendBroadcast(new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH)); + else + refresh(); + ((TextView)getView().findViewById(android.R.id.empty)).setText(R.string.TLA_no_items); + } + })); + } + @Override protected void onTaskDelete(Task task) { helper.onDeleteTask(task); @@ -94,7 +114,7 @@ public class GtasksListFragment extends SubtasksListFragment { // handle my own menus switch (id) { case MENU_REFRESH_ID: - syncService.synchronizeList(list, true, syncActionHelper.syncResultCallback); + refreshData(true); return true; case MENU_CLEAR_COMPLETED_ID: clearCompletedTasks();