Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 08facab

Browse files
authored
Merge pull request #373 from Microsoft/prevent-dialog-callback-twice
Prevent dialog from invoking callback twice
2 parents 6843ae4 + 03e250f commit 08facab

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

android/app/src/main/java/com/microsoft/codepush/react/CodePushDialog.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,15 @@ public void showDialog(String title, String message, String button1Text, String
2626
builder.setCancelable(false);
2727

2828
DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() {
29+
private boolean callbackConsumed = false;
30+
2931
@Override
30-
public void onClick(DialogInterface dialog, int which) {
32+
public synchronized void onClick(DialogInterface dialog, int which) {
33+
if (callbackConsumed) {
34+
return;
35+
}
36+
37+
callbackConsumed = true;
3138
dialog.cancel();
3239
switch (which) {
3340
case DialogInterface.BUTTON_POSITIVE:

0 commit comments

Comments
 (0)