Fixes to processing of manual order strings

pull/14/head
Sam Bosley 12 years ago
parent 2f2f96c3b1
commit f42662cfa4

@ -183,7 +183,7 @@ public class ActFmSyncThread {
}
}
private final Runnable defaultRefreshRunnable = new Runnable() {
public static final Runnable DEFAULT_REFRESH_RUNNABLE = new Runnable() {
@Override
public void run() {
Intent refresh = new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH);
@ -213,10 +213,10 @@ public class ActFmSyncThread {
if (timeForBackgroundSync()) {
repopulateQueueFromOutstandingTables();
enqueueMessage(BriefMe.instantiateBriefMeForClass(TaskListMetadata.class, NameMaps.PUSHED_AT_TASK_LIST_METADATA), defaultRefreshRunnable);
enqueueMessage(BriefMe.instantiateBriefMeForClass(Task.class, NameMaps.PUSHED_AT_TASKS), defaultRefreshRunnable);
enqueueMessage(BriefMe.instantiateBriefMeForClass(TagData.class, NameMaps.PUSHED_AT_TAGS), defaultRefreshRunnable);
enqueueMessage(BriefMe.instantiateBriefMeForClass(User.class, NameMaps.PUSHED_AT_USERS), defaultRefreshRunnable);
enqueueMessage(BriefMe.instantiateBriefMeForClass(TaskListMetadata.class, NameMaps.PUSHED_AT_TASK_LIST_METADATA), DEFAULT_REFRESH_RUNNABLE);
enqueueMessage(BriefMe.instantiateBriefMeForClass(Task.class, NameMaps.PUSHED_AT_TASKS), DEFAULT_REFRESH_RUNNABLE);
enqueueMessage(BriefMe.instantiateBriefMeForClass(TagData.class, NameMaps.PUSHED_AT_TAGS), DEFAULT_REFRESH_RUNNABLE);
enqueueMessage(BriefMe.instantiateBriefMeForClass(User.class, NameMaps.PUSHED_AT_USERS), DEFAULT_REFRESH_RUNNABLE);
setTimeForBackgroundSync(false);
}
@ -272,7 +272,7 @@ public class ActFmSyncThread {
try {
Runnable r = pendingCallbacks.remove(message);
if (r != null) {
if (r == defaultRefreshRunnable) {
if (r == DEFAULT_REFRESH_RUNNABLE) {
if (didDefaultRefreshThisLoop)
continue;
didDefaultRefreshThisLoop = true;

@ -35,7 +35,7 @@ public class ActFmSyncWaitingPool {
return;
AndroidUtilities.sleepDeep(WAIT_TIME);
while (!pendingMessages.isEmpty()) {
ActFmSyncThread.getInstance().enqueueMessage(pendingMessages.remove(0), null);
ActFmSyncThread.getInstance().enqueueMessage(pendingMessages.remove(0), ActFmSyncThread.DEFAULT_REFRESH_RUNNABLE);
}
}
};

@ -59,6 +59,10 @@ public class ReplayOutstandingEntries<T extends RemoteModel, OE extends Outstand
ActFmSyncThread.getInstance().enqueueMessage(new ChangesHappened<T, OE>(id, modelClass, dao, outstandingDao), null);
}
protected boolean shouldSaveModel(T model) {
return true;
}
private void processItem(long id, OE instance, TodorooCursor<OE> outstanding) {
try {
T model = modelClass.newInstance();
@ -79,10 +83,12 @@ public class ReplayOutstandingEntries<T extends RemoteModel, OE extends Outstand
}
model.putTransitory(SyncFlags.ACTFM_SUPPRESS_OUTSTANDING_ENTRIES, true);
dao.saveExisting(model);
if (shouldSaveModel(model)) {
dao.saveExisting(model);
if (count > 0 && !afterErrors) {
enqueueChangesHappenedMessage(id);
if (count > 0 && !afterErrors) {
enqueueChangesHappenedMessage(id);
}
}
outstanding.moveToPrevious(); // Move back one to undo the last iteration of the for loop

@ -11,6 +11,14 @@ public class ReplayTaskListMetadataOutstanding extends ReplayOutstandingEntries<
super(TaskListMetadata.class, NameMaps.TABLE_ID_TASK_LIST_METADATA, dao, outstandingDao, afterErrors);
}
@Override
protected boolean shouldSaveModel(TaskListMetadata model) {
if (model.containsNonNullValue(TaskListMetadata.TASK_IDS) &&
TaskListMetadata.taskIdsIsEmpty(model.getValue(TaskListMetadata.TASK_IDS)))
return false;
return true;
}
@Override
protected void enqueueChangesHappenedMessage(long id) {
// Do nothing

Loading…
Cancel
Save