Skip to content

Commit

Permalink
apacheGH-160 (android): Synchronize spinner dialog showing/hiding in …
Browse files Browse the repository at this point in the history
…UI thread

Fixes apache#160
  • Loading branch information
goffioul committed May 10, 2022
1 parent 9703d2a commit 3d7fe36
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/android/Notification.java
Original file line number Diff line number Diff line change
Expand Up @@ -441,14 +441,14 @@ public synchronized void dismissAll(final CallbackContext callbackContext){
* @param message The message of the dialog
*/
public synchronized void activityStart(final String title, final String message) {
if (this.spinnerDialog != null) {
this.spinnerDialog.dismiss();
this.spinnerDialog = null;
}
final Notification notification = this;
final CordovaInterface cordova = this.cordova;
Runnable runnable = new Runnable() {
public void run() {
if (notification.spinnerDialog != null) {
notification.spinnerDialog.dismiss();
notification.spinnerDialog = null;
}
notification.spinnerDialog = createProgressDialog(cordova); // new ProgressDialog(cordova.getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
notification.spinnerDialog.setTitle(title);
notification.spinnerDialog.setMessage(message);
Expand All @@ -470,10 +470,16 @@ public void onCancel(DialogInterface dialog) {
* Stop spinner.
*/
public synchronized void activityStop() {
if (this.spinnerDialog != null) {
this.spinnerDialog.dismiss();
this.spinnerDialog = null;
}
final Notification notification = this;
Runnable runnable = new Runnable() {
public void run() {
if (notification.spinnerDialog != null) {
notification.spinnerDialog.dismiss();
notification.spinnerDialog = null;
}
}
};
this.cordova.getActivity().runOnUiThread(runnable);
}

/**
Expand Down

0 comments on commit 3d7fe36

Please sign in to comment.