Sync both services sequentially when manually syncing

pull/14/head
Sam Bosley 14 years ago
parent f038670987
commit 54813cc00f

@ -9,7 +9,6 @@ import org.weloveastrid.rmilk.MilkUtilities;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.PendingIntent.CanceledException;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
@ -20,7 +19,6 @@ import android.content.pm.ResolveInfo;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.Toast;
import com.timsu.astrid.R; import com.timsu.astrid.R;
import com.todoroo.andlib.service.Autowired; import com.todoroo.andlib.service.Autowired;
@ -231,33 +229,35 @@ public class SyncActionHelper {
} else { } else {
// We have sync actions, pop up a dialogue so the user can // We have sync actions, pop up a dialogue so the user can
// select just one of them (only sync one at a time) // select just one of them (only sync one at a time)
final Object[] actions = new Object[activeSyncs]; // final Object[] actions = new Object[activeSyncs];
//
int i; // int i;
for (i = 0; i < activeV2Providers.size(); i++) // for (i = 0; i < activeV2Providers.size(); i++)
actions[i] = activeV2Providers.get(i); // actions[i] = activeV2Providers.get(i);
for (SyncAction syncAction : syncActions) // for (SyncAction syncAction : syncActions)
actions[i++] = syncAction; // actions[i++] = syncAction;
//
DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { // DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
@Override // @Override
public void onClick(DialogInterface click, int which) { // public void onClick(DialogInterface click, int which) {
if (actions[which] instanceof SyncAction) { // if (actions[which] instanceof SyncAction) {
try { // try {
((SyncAction) actions[which]).intent.send(); // ((SyncAction) actions[which]).intent.send();
Toast.makeText(activity, // Toast.makeText(activity,
R.string.SyP_progress_toast, // R.string.SyP_progress_toast,
Toast.LENGTH_LONG).show(); // Toast.LENGTH_LONG).show();
} catch (CanceledException e) { // } catch (CanceledException e) {
// // //
} // }
} else { // } else {
((SyncV2Provider) actions[which]).synchronizeActiveTasks( // ((SyncV2Provider) actions[which]).synchronizeActiveTasks(
true, syncResultCallback); // true, syncResultCallback);
} // }
} // }
}; // };
showSyncOptionMenu(actions, listener); // showSyncOptionMenu(actions, listener);
syncService.synchronizeActiveTasks(true, syncResultCallback);
} }
} }

@ -24,8 +24,8 @@ public class SyncV2Service {
* for responding to sync requests through this new API. * for responding to sync requests through this new API.
*/ */
private static final SyncV2Provider[] providers = new SyncV2Provider[] { private static final SyncV2Provider[] providers = new SyncV2Provider[] {
GtasksSyncV2Provider.getInstance(),
new ActFmSyncV2Provider(), new ActFmSyncV2Provider(),
GtasksSyncV2Provider.getInstance()
}; };
/** /**

Loading…
Cancel
Save