Push unsynced comments in general active tasks sync

pull/14/head
Sam Bosley 14 years ago
parent da2bd4d5e8
commit e721e03bc3

@ -874,7 +874,7 @@ public final class ActFmSyncService {
invokeFetchList("activity", manual, null, new UpdateListItemProcessor(), done,
"updates:" + tagData.getId(), "tag_id", tagData.getValue(TagData.REMOTE_ID));
pushQueuedUpdates(tagData);
pushQueuedUpdatesForTag(tagData);
}
/**
@ -887,7 +887,7 @@ public final class ActFmSyncService {
invokeFetchList("activity", manual, null, new UpdateListItemProcessor(), done,
"comments:" + task.getId(), "task_id", task.getValue(Task.REMOTE_ID));
pushQueuedUpdates(task);
pushQueuedUpdatesForTask(task);
}
/**
@ -898,10 +898,10 @@ public final class ActFmSyncService {
public void fetchPersonalUpdates(boolean manual, Runnable done) {
invokeFetchList("activity", manual, null, new UpdateListItemProcessor(), done, "personal");
pushAllQueuedUpdates();
}
private void pushQueuedUpdates(TagData tagData) {
private void pushQueuedUpdatesForTag(TagData tagData) {
Criterion criterion = null;
if (tagData.getValue(TagData.REMOTE_ID) < 1) {
criterion = Criterion.and(Update.REMOTE_ID.eq(0),
@ -922,7 +922,7 @@ public final class ActFmSyncService {
pushQueuedUpdates(cursor);
}
private void pushQueuedUpdates(Task task) {
private void pushQueuedUpdatesForTask(Task task) {
Criterion criterion = null;
if (task.containsNonNullValue(Task.REMOTE_ID)) {
criterion = Criterion.and(Update.REMOTE_ID.eq(0),
@ -938,6 +938,11 @@ public final class ActFmSyncService {
pushQueuedUpdates(cursor);
}
private void pushAllQueuedUpdates() {
TodorooCursor<Update> cursor = updateDao.query(Query.select(Update.ID, Update.PICTURE).where(Update.REMOTE_ID.eq(0)));
pushQueuedUpdates(cursor);
}
private void pushQueuedUpdates( TodorooCursor<Update> cursor) {
try {

@ -143,9 +143,9 @@ public class ActFmSyncV2Provider extends SyncV2Provider {
new Thread(new Runnable() {
public void run() {
callback.started();
callback.incrementMax(120);
callback.incrementMax(140);
final AtomicInteger finisher = new AtomicInteger(3);
final AtomicInteger finisher = new AtomicInteger(4);
actFmPreferenceService.recordSyncStart();
updateUserStatus();
@ -154,6 +154,8 @@ public class ActFmSyncV2Provider extends SyncV2Provider {
startTagFetcher(callback, finisher);
startUpdatesFetcher(manual, callback, finisher);
actFmSyncService.waitUntilEmpty();
startTaskFetcher(manual, callback, finisher);
@ -182,7 +184,7 @@ public class ActFmSyncV2Provider extends SyncV2Provider {
if (status.has("picture"))
Preferences.setString(ActFmPreferenceService.PREF_PICTURE, status.optString("picture"));
actFmPreferenceService.reloadThisUser();
ActFmPreferenceService.reloadThisUser();
} catch (IOException e) {
handler.handleException("actfm-sync", e, e.toString()); //$NON-NLS-1$
}
@ -238,6 +240,21 @@ public class ActFmSyncV2Provider extends SyncV2Provider {
}).start();
}
/** fetch changes to personal updates and push unpushed updates */
private void startUpdatesFetcher(final boolean manual, final SyncResultCallback callback,
final AtomicInteger finisher) {
actFmSyncService.fetchPersonalUpdates(manual, new Runnable() { // Also pushes queued updates
@Override
public void run() {
callback.incrementProgress(20);
if (finisher.decrementAndGet() == 0) {
finishSync(callback);
}
}
});
}
/** @return runnable to fetch changes to tags */
private void startTaskFetcher(final boolean manual, final SyncResultCallback callback,
final AtomicInteger finisher) {

Loading…
Cancel
Save