Fixed app crash caused by multiple callback invocation from java code. (#1289)

Added CodePushUtils.log method for logging exceptions.
This commit is contained in:
Nickolay Toropov
2018-05-24 13:52:59 +03:00
committed by Alexander Goncharov
parent 21f8388f6a
commit e0bc8b00d2
2 changed files with 18 additions and 10 deletions

View File

@@ -57,16 +57,20 @@ public class CodePushDialog extends ReactContextBaseJavaModule{
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);
}
}
};

View File

@@ -203,6 +203,10 @@ public class CodePushUtils {
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 + "\"");
}