Skip to content

Commit

Permalink
Fixed app crash caused by multiple callback invocation from java code. (
Browse files Browse the repository at this point in the history
#1289)

Added CodePushUtils.log method for logging exceptions.
  • Loading branch information
NickToropov authored and alexandergoncharov-zz committed May 24, 2018
1 parent 21f8388 commit e0bc8b0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,20 @@ private void showDialogInternal(String title, String message, String button1Text
DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
successCallback.invoke(0);
break;
case DialogInterface.BUTTON_NEGATIVE:
successCallback.invoke(1);
break;
default:
throw new CodePushUnknownException("Unknown button ID pressed.");
try {
dialog.cancel();
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
successCallback.invoke(0);
break;
case DialogInterface.BUTTON_NEGATIVE:
successCallback.invoke(1);
break;
default:
throw new CodePushUnknownException("Unknown button ID pressed.");
}
} catch (Throwable e) {
CodePushUtils.log(e);
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ public static void log(String message) {
Log.d(CodePushConstants.REACT_NATIVE_LOG_TAG, "[CodePush] " + message);
}

public static void log(Throwable tr) {
Log.e(CodePushConstants.REACT_NATIVE_LOG_TAG, "[CodePush] Exception", tr);
}

public static void logBundleUrl(String path) {
log("Loading JS bundle from \"" + path + "\"");
}
Expand Down

0 comments on commit e0bc8b0

Please sign in to comment.