@@ -51,7 +51,9 @@ public class Notification extends CordovaPlugin {
51
51
public int confirmResult = -1 ;
52
52
public ProgressDialog spinnerDialog = null ;
53
53
public ProgressDialog progressDialog = null ;
54
-
54
+
55
+ private Runnable spinnerDialogUpdate = null ;
56
+
55
57
/**
56
58
* Constructor.
57
59
*/
@@ -366,32 +368,39 @@ public synchronized void activityStart(final String title, final String message,
366
368
}*/
367
369
final Notification notification = this ;
368
370
final CordovaInterface cordova = this .cordova ;
369
- Runnable runnable = new Runnable () {
371
+ this . spinnerDialogUpdate = new Runnable () {
370
372
public void run () {
371
- if (notification .spinnerDialog != null ) { //update
372
- notification .spinnerDialog .setTitle (title );
373
- notification .spinnerDialog .setMessage (message );
374
- notification .spinnerDialog .setCancelable (cancelable );
375
- if (!notification .spinnerDialog .isShowing ()) {
373
+ synchronized (notification ) {
374
+ if (notification .spinnerDialogUpdate != this ) {
375
+ return ; // operation aborted before run
376
+ }
377
+ notification .spinnerDialogUpdate = null ;
378
+
379
+ if (notification .spinnerDialog != null ) { //update
380
+ notification .spinnerDialog .setTitle (title );
381
+ notification .spinnerDialog .setMessage (message );
382
+ notification .spinnerDialog .setCancelable (cancelable );
383
+ if (!notification .spinnerDialog .isShowing ()) {
384
+ notification .spinnerDialog .show ();
385
+ }
386
+ } else {
387
+ notification .spinnerDialog = createProgressDialog (cordova ); // new ProgressDialog(cordova.getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
388
+ notification .spinnerDialog .setTitle (title );
389
+ notification .spinnerDialog .setMessage (message );
390
+ notification .spinnerDialog .setCancelable (cancelable );
391
+ notification .spinnerDialog .setIndeterminate (true );
392
+ notification .spinnerDialog .setOnCancelListener (
393
+ new DialogInterface .OnCancelListener () {
394
+ public void onCancel (DialogInterface dialog ) {
395
+ notification .spinnerDialog = null ;
396
+ }
397
+ });
376
398
notification .spinnerDialog .show ();
377
399
}
378
- } else {
379
- notification .spinnerDialog = createProgressDialog (cordova ); // new ProgressDialog(cordova.getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
380
- notification .spinnerDialog .setTitle (title );
381
- notification .spinnerDialog .setMessage (message );
382
- notification .spinnerDialog .setCancelable (cancelable );
383
- notification .spinnerDialog .setIndeterminate (true );
384
- notification .spinnerDialog .setOnCancelListener (
385
- new DialogInterface .OnCancelListener () {
386
- public void onCancel (DialogInterface dialog ) {
387
- notification .spinnerDialog = null ;
388
- }
389
- });
390
- notification .spinnerDialog .show ();
391
- }
400
+ }
392
401
}
393
402
};
394
- this .cordova .getActivity ().runOnUiThread (runnable );
403
+ this .cordova .getActivity ().runOnUiThread (this . spinnerDialogUpdate );
395
404
}
396
405
397
406
/**
@@ -402,6 +411,9 @@ public synchronized void activityStop() {
402
411
this .spinnerDialog .dismiss ();
403
412
this .spinnerDialog = null ;
404
413
}
414
+ if (this .spinnerDialogUpdate != null ) {
415
+ this .spinnerDialogUpdate = null ;
416
+ }
405
417
}
406
418
407
419
/**
0 commit comments