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);
}
} 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) {
FlurryAgent.onError("rtm-authenticate", AstridUtilities.throwableToString(e),
SynchronizationProvider.class.getSimpleName());

@ -64,32 +64,38 @@ public abstract class SynchronizationProvider {
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 caller
*/
void synchronizeService(final Context activity, Synchronizer caller) {
void synchronizeService(final Context context, Synchronizer caller) {
this.synchronizer = caller;
this.syncHandler = caller.getHandler();
if(!isBackgroundService()) {
syncHandler.post(new Runnable() {
@Override
public void run() {
SynchronizationProvider.progressDialog = new ProgressDialog(activity);
progressDialog.setIcon(android.R.drawable.ic_dialog_alert);
progressDialog.setTitle("Synchronization");
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressDialog.setMax(100);
progressDialog.setMessage("Checking Authorization...");
progressDialog.setProgress(0);
progressDialog.setCancelable(false);
progressDialog.show();
}
});
try {
this.syncHandler = new Handler();
syncHandler.post(new Runnable() {
@Override
public void run() {
SynchronizationProvider.progressDialog = new ProgressDialog(context);
progressDialog.setIcon(android.R.drawable.ic_dialog_alert);
progressDialog.setTitle("Synchronization");
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressDialog.setMax(100);
progressDialog.setMessage("Checking Authorization...");
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 */

@ -24,7 +24,6 @@ import java.util.Date;
import android.app.Activity;
import android.content.Context;
import android.os.Handler;
import android.util.Log;
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(!isService) {
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
/** Handler for sending jobs to the UI thread */
private Handler handler = null;
/** Current step in the sync process */
private int currentStep = 0;
@ -167,10 +161,6 @@ public class Synchronizer {
return singleTaskForSync;
}
Handler getHandler() {
return handler;
}
/** Called to do the next step of synchronization. */
void continueSynchronization(Context context) {
try {

Loading…
Cancel
Save