From a58844e05db4208d3155eb49355e2ecbb26b66d7 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Mon, 22 Oct 2012 14:29:15 -0700 Subject: [PATCH] Fill out the implementation of pushUser in actfmsyncservice --- .../todoroo/astrid/actfm/sync/ActFmSyncService.java | 13 +++++++++++-- .../todoroo/astrid/people/PersonViewFragment.java | 3 +++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncService.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncService.java index 95eeae056..4890aadcd 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncService.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncService.java @@ -55,6 +55,7 @@ import com.todoroo.astrid.dao.TagDataDao; import com.todoroo.astrid.dao.TaskDao; import com.todoroo.astrid.dao.TaskDao.TaskCriteria; import com.todoroo.astrid.dao.UpdateDao; +import com.todoroo.astrid.dao.UserDao; import com.todoroo.astrid.data.Metadata; import com.todoroo.astrid.data.MetadataApiDao.MetadataCriteria; import com.todoroo.astrid.data.RemoteModel; @@ -99,6 +100,7 @@ public final class ActFmSyncService { @Autowired TaskDao taskDao; @Autowired TagDataDao tagDataDao; @Autowired UpdateDao updateDao; + @Autowired UserDao userDao; @Autowired MetadataDao metadataDao; @Autowired ABTestEventReportingService abTestEventReportingService; @@ -913,8 +915,15 @@ public final class ActFmSyncService { params.add("id"); params.add(model.getValue(User.REMOTE_ID)); params.add("status"); params.add(model.getValue(User.PENDING_STATUS)); - JSONObject result = actFmInvoker.invoke("user_set_status", params); - System.err.println("RESULT: " + result); + JSONObject result = actFmInvoker.invoke("user_set_status", params.toArray(new Object[params.size()])); + if (result.optString("status").equals("success")) { + String newStatus = result.optString("friendship_status"); + if (!TextUtils.isEmpty(newStatus)) { + model.setValue(User.STATUS, newStatus); + model.setValue(User.PENDING_STATUS, ""); + userDao.saveExisting(model); + } + } } catch (IOException e) { handleException("user-status", e); } diff --git a/astrid/plugin-src/com/todoroo/astrid/people/PersonViewFragment.java b/astrid/plugin-src/com/todoroo/astrid/people/PersonViewFragment.java index cf438f503..5de6482e5 100644 --- a/astrid/plugin-src/com/todoroo/astrid/people/PersonViewFragment.java +++ b/astrid/plugin-src/com/todoroo/astrid/people/PersonViewFragment.java @@ -18,6 +18,7 @@ import com.todoroo.andlib.service.ContextManager; import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.andlib.utility.Preferences; import com.todoroo.astrid.actfm.sync.ActFmPreferenceService; +import com.todoroo.astrid.actfm.sync.ActFmSyncService; import com.todoroo.astrid.activity.TaskListFragment; import com.todoroo.astrid.api.AstridApiConstants; import com.todoroo.astrid.dao.UserDao; @@ -43,6 +44,8 @@ public class PersonViewFragment extends TaskListFragment { @Autowired ActFmPreferenceService actFmPreferenceService; + @Autowired ActFmSyncService actFmSyncService; + private AsyncImageView userImage; private TextView userSubtitle; private TextView userStatusButton;