Some improvements to tag order syncing, better timing to ensure most accurate data pushed

pull/14/head
Sam Bosley 12 years ago
parent 5c39dc55d3
commit dc2c37edaf

@ -600,8 +600,16 @@ public final class ActFmSyncService {
public void pushTagOrderingImmediately(TagData tagData) {
if (tagOrderQueue.contains(tagData.getId())) {
tagOrderQueue.remove(tagData.getId());
pushTagOrdering(tagData);
}
pushTagOrdering(tagData);
}
public boolean cancelTagOrderingPush(long tagDataId) {
if (tagOrderQueue.contains(tagDataId)) {
tagOrderQueue.remove(tagDataId);
return true;
}
return false;
}
private void pushTagOrdering(TagData tagData) {

@ -452,8 +452,8 @@ public class ActFmSyncV2Provider extends SyncV2Provider {
if(!noRemoteId) {
actFmSyncService.waitUntilEmpty();
actFmSyncService.pushTagOrderingImmediately(tagData);
fetchTasksForTag(tagData, manual, callback, finisher);
boolean orderPushQueued = actFmSyncService.cancelTagOrderingPush(tagData.getId());
fetchTasksForTag(tagData, manual, orderPushQueued, callback, finisher);
fetchUpdatesForTag(tagData, manual, callback, finisher);
}
@ -494,7 +494,7 @@ public class ActFmSyncV2Provider extends SyncV2Provider {
actFmSyncService.fetchTag(tagData);
if(noRemoteId) {
fetchTasksForTag(tagData, manual, callback, finisher);
fetchTasksForTag(tagData, manual, true, callback, finisher);
fetchUpdatesForTag(tagData, manual, callback, finisher);
}
@ -527,14 +527,17 @@ public class ActFmSyncV2Provider extends SyncV2Provider {
});
}
private void fetchTasksForTag(final TagData tagData, boolean manual, final SyncResultCallback callback,
private void fetchTasksForTag(final TagData tagData, boolean manual, final boolean pushOrder, final SyncResultCallback callback,
final AtomicInteger finisher) {
actFmSyncService.fetchTasksForTag(tagData, manual, new Runnable() {
@Override
public void run() {
pushQueuedTasksByTag(tagData, callback, finisher);
actFmSyncService.fetchTagOrder(tagData);
if (pushOrder)
actFmSyncService.pushTagOrderingImmediately(tagData);
else
actFmSyncService.fetchTagOrder(tagData);
callback.incrementProgress(30);
if(finisher.decrementAndGet() == 0)

Loading…
Cancel
Save