|
|
@ -120,7 +120,7 @@ public final class ActFmSyncService {
|
|
|
|
taskDao.addListener(new ModelUpdateListener<Task>() {
|
|
|
|
taskDao.addListener(new ModelUpdateListener<Task>() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onModelUpdated(final Task model) {
|
|
|
|
public void onModelUpdated(final Task model) {
|
|
|
|
if(Flags.checkAndClear(Flags.ACTFM_SUPPRESS_SYNC))
|
|
|
|
if(model.checkAndClearTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC))
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
if (actFmPreferenceService.isOngoing() && model.getTransitory("task-edit-save") == null)
|
|
|
|
if (actFmPreferenceService.isOngoing() && model.getTransitory("task-edit-save") == null)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -149,7 +149,7 @@ public final class ActFmSyncService {
|
|
|
|
updateDao.addListener(new ModelUpdateListener<Update>() {
|
|
|
|
updateDao.addListener(new ModelUpdateListener<Update>() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onModelUpdated(final Update model) {
|
|
|
|
public void onModelUpdated(final Update model) {
|
|
|
|
if(Flags.checkAndClear(Flags.ACTFM_SUPPRESS_SYNC))
|
|
|
|
if(model.checkAndClearTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC))
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
if (actFmPreferenceService.isOngoing())
|
|
|
|
if (actFmPreferenceService.isOngoing())
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -169,7 +169,7 @@ public final class ActFmSyncService {
|
|
|
|
tagDataDao.addListener(new ModelUpdateListener<TagData>() {
|
|
|
|
tagDataDao.addListener(new ModelUpdateListener<TagData>() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onModelUpdated(final TagData model) {
|
|
|
|
public void onModelUpdated(final TagData model) {
|
|
|
|
if(Flags.checkAndClear(Flags.ACTFM_SUPPRESS_SYNC))
|
|
|
|
if(model.checkAndClearTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC))
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
if (actFmPreferenceService.isOngoing())
|
|
|
|
if (actFmPreferenceService.isOngoing())
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -439,7 +439,7 @@ public final class ActFmSyncService {
|
|
|
|
task.setValue(Task.LAST_SYNC, DateUtilities.now() + 1000L);
|
|
|
|
task.setValue(Task.LAST_SYNC, DateUtilities.now() + 1000L);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Flags.set(Flags.ACTFM_SUPPRESS_SYNC);
|
|
|
|
task.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true);
|
|
|
|
taskDao.saveExisting(task);
|
|
|
|
taskDao.saveExisting(task);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -558,7 +558,7 @@ public final class ActFmSyncService {
|
|
|
|
JSONObject result = actFmInvoker.invoke("tag_save", params.toArray(new Object[params.size()]));
|
|
|
|
JSONObject result = actFmInvoker.invoke("tag_save", params.toArray(new Object[params.size()]));
|
|
|
|
if(newlyCreated) {
|
|
|
|
if(newlyCreated) {
|
|
|
|
tagData.setValue(TagData.REMOTE_ID, result.optLong("id"));
|
|
|
|
tagData.setValue(TagData.REMOTE_ID, result.optLong("id"));
|
|
|
|
Flags.set(Flags.ACTFM_SUPPRESS_SYNC);
|
|
|
|
tagData.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true);
|
|
|
|
tagDataDao.saveExisting(tagData);
|
|
|
|
tagDataDao.saveExisting(tagData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (ActFmServiceException e) {
|
|
|
|
} catch (ActFmServiceException e) {
|
|
|
@ -618,7 +618,7 @@ public final class ActFmSyncService {
|
|
|
|
JSONObject item = list.getJSONObject(i);
|
|
|
|
JSONObject item = list.getJSONObject(i);
|
|
|
|
readIds(locals, item, remote);
|
|
|
|
readIds(locals, item, remote);
|
|
|
|
JsonHelper.tagFromJson(item, remote);
|
|
|
|
JsonHelper.tagFromJson(item, remote);
|
|
|
|
Flags.set(Flags.ACTFM_SUPPRESS_SYNC);
|
|
|
|
remote.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true);
|
|
|
|
tagDataService.save(remote);
|
|
|
|
tagDataService.save(remote);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -660,7 +660,7 @@ public final class ActFmSyncService {
|
|
|
|
"token", token);
|
|
|
|
"token", token);
|
|
|
|
|
|
|
|
|
|
|
|
JsonHelper.tagFromJson(result, tagData);
|
|
|
|
JsonHelper.tagFromJson(result, tagData);
|
|
|
|
Flags.set(Flags.ACTFM_SUPPRESS_SYNC);
|
|
|
|
tagData.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true);
|
|
|
|
tagDataService.save(tagData);
|
|
|
|
tagDataService.save(tagData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -682,7 +682,7 @@ public final class ActFmSyncService {
|
|
|
|
|
|
|
|
|
|
|
|
ArrayList<Metadata> metadata = new ArrayList<Metadata>();
|
|
|
|
ArrayList<Metadata> metadata = new ArrayList<Metadata>();
|
|
|
|
JsonHelper.taskFromJson(result, task, metadata);
|
|
|
|
JsonHelper.taskFromJson(result, task, metadata);
|
|
|
|
Flags.set(Flags.ACTFM_SUPPRESS_SYNC);
|
|
|
|
task.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true);
|
|
|
|
taskService.save(task);
|
|
|
|
taskService.save(task);
|
|
|
|
metadataService.synchronizeMetadata(task.getId(), metadata, Metadata.KEY.eq(TagService.KEY));
|
|
|
|
metadataService.synchronizeMetadata(task.getId(), metadata, Metadata.KEY.eq(TagService.KEY));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -743,7 +743,7 @@ public final class ActFmSyncService {
|
|
|
|
remote.getValue(Task.DUE_DATE) < DateUtilities.now())
|
|
|
|
remote.getValue(Task.DUE_DATE) < DateUtilities.now())
|
|
|
|
remote.setFlag(Task.REMINDER_FLAGS, Task.NOTIFY_AFTER_DEADLINE, false);
|
|
|
|
remote.setFlag(Task.REMINDER_FLAGS, Task.NOTIFY_AFTER_DEADLINE, false);
|
|
|
|
|
|
|
|
|
|
|
|
Flags.set(Flags.ACTFM_SUPPRESS_SYNC);
|
|
|
|
remote.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true);
|
|
|
|
taskService.save(remote);
|
|
|
|
taskService.save(remote);
|
|
|
|
ids.add(remote.getId());
|
|
|
|
ids.add(remote.getId());
|
|
|
|
metadataService.synchronizeMetadata(remote.getId(), metadata, MetadataCriteria.withKey(TagService.KEY));
|
|
|
|
metadataService.synchronizeMetadata(remote.getId(), metadata, MetadataCriteria.withKey(TagService.KEY));
|
|
|
@ -800,7 +800,7 @@ public final class ActFmSyncService {
|
|
|
|
StatisticsService.reportEvent(StatisticsConstants.ACTFM_TASK_COMPLETED);
|
|
|
|
StatisticsService.reportEvent(StatisticsConstants.ACTFM_TASK_COMPLETED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Flags.set(Flags.ACTFM_SUPPRESS_SYNC);
|
|
|
|
remote.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true);
|
|
|
|
taskService.save(remote);
|
|
|
|
taskService.save(remote);
|
|
|
|
ids.add(remote.getId());
|
|
|
|
ids.add(remote.getId());
|
|
|
|
metadataService.synchronizeMetadata(remote.getId(), metadata, MetadataCriteria.withKey(TagService.KEY));
|
|
|
|
metadataService.synchronizeMetadata(remote.getId(), metadata, MetadataCriteria.withKey(TagService.KEY));
|
|
|
@ -943,7 +943,7 @@ public final class ActFmSyncService {
|
|
|
|
readIds(locals, item, remote);
|
|
|
|
readIds(locals, item, remote);
|
|
|
|
JsonHelper.updateFromJson(item, remote);
|
|
|
|
JsonHelper.updateFromJson(item, remote);
|
|
|
|
|
|
|
|
|
|
|
|
Flags.set(Flags.ACTFM_SUPPRESS_SYNC);
|
|
|
|
remote.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true);
|
|
|
|
if(remote.getId() == AbstractModel.NO_ID)
|
|
|
|
if(remote.getId() == AbstractModel.NO_ID)
|
|
|
|
updateDao.createNew(remote);
|
|
|
|
updateDao.createNew(remote);
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -1127,7 +1127,7 @@ public final class ActFmSyncService {
|
|
|
|
public static void updateFromJson(JSONObject json, Update model) throws JSONException {
|
|
|
|
public static void updateFromJson(JSONObject json, Update model) throws JSONException {
|
|
|
|
model.setValue(Update.REMOTE_ID, json.getLong("id"));
|
|
|
|
model.setValue(Update.REMOTE_ID, json.getLong("id"));
|
|
|
|
readUser(json.getJSONObject("user"), model, Update.USER_ID, Update.USER);
|
|
|
|
readUser(json.getJSONObject("user"), model, Update.USER_ID, Update.USER);
|
|
|
|
if (json.has("other_user")) {
|
|
|
|
if (!json.isNull("other_user")) {
|
|
|
|
readUser(json.getJSONObject("other_user"), model, Update.OTHER_USER_ID, Update.OTHER_USER);
|
|
|
|
readUser(json.getJSONObject("other_user"), model, Update.OTHER_USER_ID, Update.OTHER_USER);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
model.setValue(Update.ACTION, json.getString("action"));
|
|
|
|
model.setValue(Update.ACTION, json.getString("action"));
|
|
|
|