Fixes for auto-synchronization. Yay for testing.

pull/14/head
Tim Su 15 years ago
parent 655c839550
commit e98cbb0fa0

@ -127,9 +127,10 @@ public class TaskList extends Activity {
// sync now if requested
if(synchronizeNow) {
Synchronizer.synchronize(this, true, null);
synchronizeNow = false;
Synchronizer.synchronize(this, false, null);
}
// if we have no filter tag, we're not on the last task
if(getCurrentSubActivity() == taskListWTag &&
((TaskListSubActivity)taskListWTag).getFilterTag() == null) {

@ -238,6 +238,9 @@ public class RTMSyncProvider extends SynchronizationProvider {
Date syncTime = new Date(System.currentTimeMillis() + 1000);
Preferences.setSyncRTMLastSync(context, syncTime);
// on with the synchronization
Synchronizer.continueSynchronization(context);
} catch (Exception e) {
showError(context, e, null);
}

@ -27,7 +27,6 @@ import java.util.LinkedList;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.Resources;
import android.os.Handler;
import android.util.Log;
@ -497,15 +496,11 @@ public abstract class SynchronizationProvider {
progressDialog.hide();
Resources r = context.getResources();
if(Preferences.shouldSuppressSyncDialogs(context))
if(Preferences.shouldSuppressSyncDialogs(context)) {
return;
}
Dialog.OnClickListener finishListener = new Dialog.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
Synchronizer.continueSynchronization(context);
}
};
Dialog.OnClickListener finishListener = null;
// nothing updated
if(localCreatedTasks + localUpdatedTasks + localDeletedTasks +

@ -60,14 +60,17 @@ public class SynchronizationService extends Service {
// figure out last synchronize time
Date lastSyncDate = Preferences.getSyncLastSync(context);
Date lastAutoSyncDate = Preferences.getSyncLastSyncAttempt(context);
long latestSyncMillis = 0;
// if user never synchronized, give them a full offset period before bg sync
long latestSyncMillis = System.currentTimeMillis();
if(lastSyncDate != null)
latestSyncMillis = lastSyncDate.getTime();
if(lastAutoSyncDate != null && lastAutoSyncDate.getTime() > latestSyncMillis)
latestSyncMillis = lastAutoSyncDate.getTime();
long offset = 0;
if(latestSyncMillis != 0)
offset = Math.max(0, latestSyncMillis + interval - System.currentTimeMillis());
offset = Math.min(offset, Math.max(0, latestSyncMillis + interval -
System.currentTimeMillis()));
timer.scheduleAtFixedRate(new TimerTask() {
@Override

@ -114,7 +114,7 @@ public class Synchronizer {
private static boolean autoSync;
/** Called to do the next step of synchronization. Run me on the UI thread! */
/** Called to do the next step of synchronization. */
static void continueSynchronization(Context context) {
ServiceWrapper serviceWrapper =
ServiceWrapper.values()[currentStep];
@ -124,7 +124,7 @@ public class Synchronizer {
continueSynchronization(context);
break;
case RTM:
if(Preferences.shouldSyncRTM(context)) {
if(serviceWrapper.isActivated(context)) {
servicesSynced++;
serviceWrapper.service.synchronizeService(context, autoSync);
} else {

Loading…
Cancel
Save