From 561612ff7ce0a87f400d2efdd615337a3247c713 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Mon, 1 Apr 2013 11:35:03 -0700 Subject: [PATCH] First draft at fetching tasks for a user --- .../todoroo/astrid/people/PersonViewFragment.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/people/PersonViewFragment.java b/astrid/plugin-src/com/todoroo/astrid/people/PersonViewFragment.java index cbf383b8d..6ae1c1e82 100644 --- a/astrid/plugin-src/com/todoroo/astrid/people/PersonViewFragment.java +++ b/astrid/plugin-src/com/todoroo/astrid/people/PersonViewFragment.java @@ -19,6 +19,7 @@ import android.widget.TextView; import com.actionbarsherlock.view.Menu; import com.timsu.astrid.R; +import com.todoroo.andlib.data.TodorooCursor; import com.todoroo.andlib.service.Autowired; import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.astrid.actfm.sync.ActFmPreferenceService; @@ -29,6 +30,7 @@ import com.todoroo.astrid.actfm.sync.messages.BriefMe; import com.todoroo.astrid.activity.TaskListFragment; import com.todoroo.astrid.dao.UserDao; import com.todoroo.astrid.data.RemoteModel; +import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.User; import com.todoroo.astrid.helper.AsyncImageView; import com.todoroo.astrid.service.SyncV2Service; @@ -224,7 +226,15 @@ public class PersonViewFragment extends TaskListFragment { @Override public void runOnErrors(List errors) {/**/} }; - ActFmSyncThread.getInstance().enqueueMessage(new BriefMe(User.class, user.getValue(User.UUID), user.getValue(User.PUSHED_AT)), callback); + long pushedAt = user.getValue(User.PUSHED_AT); + JSONArray existingTasks = new JSONArray(); + TodorooCursor tasksCursor = (TodorooCursor) taskAdapter.getCursor(); + for (tasksCursor.moveToFirst(); !tasksCursor.isAfterLast(); tasksCursor.moveToNext()) { + existingTasks.put(tasksCursor.get(Task.UUID)); + } + + BriefMe briefMe = new BriefMe(Task.class, null, pushedAt, "user_id", user.getValue(User.UUID), "existing_tasks", existingTasks); //$NON-NLS-1$//$NON-NLS-2$ + ActFmSyncThread.getInstance().enqueueMessage(briefMe, callback); } }