From f43a318f1ea331d342dc11b3460fd2f0fb73d652 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Thu, 7 Feb 2013 15:49:15 -0800 Subject: [PATCH] Sync history and comments in both comment fragments --- .../todoroo/astrid/actfm/CommentsFragment.java | 15 +-------------- .../todoroo/astrid/actfm/TagCommentsFragment.java | 14 ++++++++++++-- .../astrid/actfm/TaskCommentsFragment.java | 10 ++++++++-- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/CommentsFragment.java b/astrid/plugin-src/com/todoroo/astrid/actfm/CommentsFragment.java index bbfbf6ef1..872e4c95d 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/CommentsFragment.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/CommentsFragment.java @@ -48,7 +48,6 @@ import com.todoroo.astrid.dao.UserActivityDao; import com.todoroo.astrid.data.RemoteModel; import com.todoroo.astrid.data.UserActivity; import com.todoroo.astrid.helper.ImageDiskCache; -import com.todoroo.astrid.helper.ProgressBarSyncResultCallback; import com.todoroo.astrid.service.StatisticsService; public abstract class CommentsFragment extends ListFragment { @@ -264,21 +263,10 @@ public abstract class CommentsFragment extends ListFragment { protected void refreshActivity(boolean manual) { if (actFmPreferenceService.isLoggedIn()) { - final ProgressBarSyncResultCallback callback = new ProgressBarSyncResultCallback( - getActivity(), this, R.id.comments_progressBar, new Runnable() { - @Override - public void run() { - refreshUpdatesList(); - } - }); - - callback.started(); - callback.incrementMax(100); Runnable doneRunnable = new Runnable() { @Override public void run() { - callback.incrementProgress(50); - callback.finished(); + refreshUpdatesList(); } }; if (hasModel()) { @@ -287,7 +275,6 @@ public abstract class CommentsFragment extends ListFragment { // actFmSyncService.fetchPersonalUpdates(manual, doneRunnable); doneRunnable.run(); } - callback.incrementProgress(50); } } diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/TagCommentsFragment.java b/astrid/plugin-src/com/todoroo/astrid/actfm/TagCommentsFragment.java index 32fe1f1ef..efc6be4ff 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/TagCommentsFragment.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/TagCommentsFragment.java @@ -19,8 +19,13 @@ import com.timsu.astrid.R; import com.todoroo.andlib.service.Autowired; import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.andlib.utility.Preferences; +import com.todoroo.astrid.actfm.sync.ActFmSyncThread; +import com.todoroo.astrid.actfm.sync.messages.BriefMe; +import com.todoroo.astrid.actfm.sync.messages.FetchHistory; +import com.todoroo.astrid.actfm.sync.messages.NameMaps; import com.todoroo.astrid.activity.TaskListActivity; import com.todoroo.astrid.adapter.UpdateAdapter; +import com.todoroo.astrid.dao.TagDataDao; import com.todoroo.astrid.data.RemoteModel; import com.todoroo.astrid.data.TagData; import com.todoroo.astrid.data.Task; @@ -39,6 +44,9 @@ public class TagCommentsFragment extends CommentsFragment { @Autowired private TagDataService tagDataService; + @Autowired + private TagDataDao tagDataDao; + public TagCommentsFragment() { super(); } @@ -119,8 +127,10 @@ public class TagCommentsFragment extends CommentsFragment { @Override protected void performFetch(boolean manual, Runnable done) { - done.run(); -// actFmSyncService.fetchUpdatesForTag(tagData, manual, done); + if (tagData != null) { + ActFmSyncThread.getInstance().enqueueMessage(new BriefMe(TagData.class, tagData.getUuid(), tagData.getValue(TagData.PUSHED_AT)), done); + new FetchHistory(tagDataDao, TagData.HISTORY_FETCH_DATE, NameMaps.TABLE_ID_TAGS, tagData.getUuid(), null, tagData.getValue(TagData.HISTORY_FETCH_DATE), true).execute(); + } } @Override diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/TaskCommentsFragment.java b/astrid/plugin-src/com/todoroo/astrid/actfm/TaskCommentsFragment.java index 628dd4b33..a5e0de47f 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/TaskCommentsFragment.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/TaskCommentsFragment.java @@ -8,6 +8,10 @@ import android.widget.ListView; import com.timsu.astrid.R; import com.todoroo.andlib.service.Autowired; import com.todoroo.andlib.utility.DateUtilities; +import com.todoroo.astrid.actfm.sync.ActFmSyncThread; +import com.todoroo.astrid.actfm.sync.messages.BriefMe; +import com.todoroo.astrid.actfm.sync.messages.FetchHistory; +import com.todoroo.astrid.actfm.sync.messages.NameMaps; import com.todoroo.astrid.adapter.UpdateAdapter; import com.todoroo.astrid.dao.TaskDao; import com.todoroo.astrid.data.Task; @@ -76,8 +80,10 @@ public class TaskCommentsFragment extends CommentsFragment { @Override protected void performFetch(boolean manual, Runnable done) { - done.run(); -// actFmSyncService.fetchUpdatesForTask(task, manual, done); + if (task != null) { + ActFmSyncThread.getInstance().enqueueMessage(new BriefMe(Task.class, task.getUuid(), task.getValue(Task.PUSHED_AT)), done); + new FetchHistory(taskDao, Task.HISTORY_FETCH_DATE, NameMaps.TABLE_ID_TASKS, task.getUuid(), null, task.getValue(Task.HISTORY_FETCH_DATE), false).execute(); + } } @Override