|
|
|
@ -12,7 +12,7 @@ import com.todoroo.astrid.service.SyncV2Service.SyncResultCallback;
|
|
|
|
|
|
|
|
|
|
public class ProgressBarSyncResultCallback implements SyncResultCallback {
|
|
|
|
|
|
|
|
|
|
private final ProgressBar progressBar;
|
|
|
|
|
private ProgressBar progressBar;
|
|
|
|
|
private final Activity activity;
|
|
|
|
|
private final Runnable onFinished;
|
|
|
|
|
|
|
|
|
@ -23,6 +23,10 @@ public class ProgressBarSyncResultCallback implements SyncResultCallback {
|
|
|
|
|
this.progressBar = (ProgressBar) activity.findViewById(progressBarId);
|
|
|
|
|
this.activity = activity;
|
|
|
|
|
this.onFinished = onFinished;
|
|
|
|
|
|
|
|
|
|
if(progressBar == null)
|
|
|
|
|
progressBar = new ProgressBar(activity);
|
|
|
|
|
|
|
|
|
|
progressBar.setProgress(0);
|
|
|
|
|
progressBar.setMax(0);
|
|
|
|
|
}
|
|
|
|
@ -33,6 +37,7 @@ public class ProgressBarSyncResultCallback implements SyncResultCallback {
|
|
|
|
|
activity.runOnUiThread(new Runnable() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
try {
|
|
|
|
|
progressBar.setMax(100);
|
|
|
|
|
progressBar.setProgress(100);
|
|
|
|
|
AlphaAnimation animation = new AlphaAnimation(1, 0);
|
|
|
|
@ -41,6 +46,9 @@ public class ProgressBarSyncResultCallback implements SyncResultCallback {
|
|
|
|
|
progressBar.startAnimation(animation);
|
|
|
|
|
|
|
|
|
|
onFinished.run();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// ignore, view could have been destroyed
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
new Thread() {
|
|
|
|
@ -50,7 +58,11 @@ public class ProgressBarSyncResultCallback implements SyncResultCallback {
|
|
|
|
|
activity.runOnUiThread(new Runnable() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
try {
|
|
|
|
|
progressBar.setVisibility(View.GONE);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// ignore
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
@ -63,7 +75,11 @@ public class ProgressBarSyncResultCallback implements SyncResultCallback {
|
|
|
|
|
activity.runOnUiThread(new Runnable() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
try {
|
|
|
|
|
progressBar.setMax(progressBar.getMax() + incrementBy);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// ignore
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
@ -73,7 +89,11 @@ public class ProgressBarSyncResultCallback implements SyncResultCallback {
|
|
|
|
|
activity.runOnUiThread(new Runnable() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
try {
|
|
|
|
|
progressBar.incrementProgressBy(incrementBy);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// ignore
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|