Fix for the "greyed out task list" bug, and adding another catch for IllegalStateException aughhh.

pull/14/head
Tim Su 17 years ago
parent 96fafbf88c
commit 3559181728

@ -173,6 +173,15 @@ public class RTMSyncProvider extends SynchronizationProvider {
performSync(context); performSync(context);
} }
} catch (IllegalStateException e) {
// occurs when application was closed
FlurryAgent.onError("rtm-authenticate-caught", AstridUtilities.throwableToString(e),
SynchronizationProvider.class.getSimpleName());
Log.e("rtmsync", "Illegal State during Sync", e);
} catch (Exception e) { } catch (Exception e) {
FlurryAgent.onError("rtm-authenticate", AstridUtilities.throwableToString(e), FlurryAgent.onError("rtm-authenticate", AstridUtilities.throwableToString(e),
SynchronizationProvider.class.getSimpleName()); SynchronizationProvider.class.getSimpleName());

@ -64,32 +64,38 @@ public abstract class SynchronizationProvider {
this.id = id; this.id = id;
} }
/** Does some setup and then invokes implemented synchronize method /** Does some setup and then invokes implemented synchronize method. Call me
* on the UI thread!
*
* @param activity * @param activity
* @param caller * @param caller
*/ */
void synchronizeService(final Context activity, Synchronizer caller) { void synchronizeService(final Context context, Synchronizer caller) {
this.synchronizer = caller; this.synchronizer = caller;
this.syncHandler = caller.getHandler();
if(!isBackgroundService()) { if(!isBackgroundService()) {
syncHandler.post(new Runnable() { try {
@Override this.syncHandler = new Handler();
public void run() { syncHandler.post(new Runnable() {
SynchronizationProvider.progressDialog = new ProgressDialog(activity); @Override
progressDialog.setIcon(android.R.drawable.ic_dialog_alert); public void run() {
progressDialog.setTitle("Synchronization"); SynchronizationProvider.progressDialog = new ProgressDialog(context);
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progressDialog.setIcon(android.R.drawable.ic_dialog_alert);
progressDialog.setMax(100); progressDialog.setTitle("Synchronization");
progressDialog.setMessage("Checking Authorization..."); progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressDialog.setProgress(0); progressDialog.setMax(100);
progressDialog.setCancelable(false); progressDialog.setMessage("Checking Authorization...");
progressDialog.show(); progressDialog.setProgress(0);
} progressDialog.setCancelable(false);
}); }
});
} catch (IllegalStateException e) {
Log.w("sync", "Wasn't in UI thread when creating handler.");
syncHandler = null;
}
} }
synchronize(activity); synchronize(context);
} }
/** Synchronize with the service */ /** Synchronize with the service */

@ -24,7 +24,6 @@ import java.util.Date;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.os.Handler;
import android.util.Log; import android.util.Log;
import com.flurry.android.FlurryAgent; import com.flurry.android.FlurryAgent;
@ -81,11 +80,9 @@ public class Synchronizer {
// if we're not the autosync service, stop it. also create handler // if we're not the autosync service, stop it. also create handler
if(!isService) { if(!isService) {
SynchronizationService.stop(); SynchronizationService.stop();
handler = new Handler();
} }
ServiceWrapper.RTM.service.synchronizeService(context, this); continueSynchronization(context);
//continueSynchronization(context);
} }
@ -141,9 +138,6 @@ public class Synchronizer {
// Internal state for the synchronization process // Internal state for the synchronization process
/** Handler for sending jobs to the UI thread */
private Handler handler = null;
/** Current step in the sync process */ /** Current step in the sync process */
private int currentStep = 0; private int currentStep = 0;
@ -167,10 +161,6 @@ public class Synchronizer {
return singleTaskForSync; return singleTaskForSync;
} }
Handler getHandler() {
return handler;
}
/** Called to do the next step of synchronization. */ /** Called to do the next step of synchronization. */
void continueSynchronization(Context context) { void continueSynchronization(Context context) {
try { try {

Loading…
Cancel
Save