Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue with [Android] restartApp() throwing exception w/ release build #861

Merged
merged 5 commits into from
Jun 1, 2017
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ private void setJSBundle(ReactInstanceManager instanceManager, String latestJSBu

Method[] methods = jsBundleLoaderClass.getDeclaredMethods();
for (Method method : methods) {
if (method.getName().equals("createFileLoader")) {
String createFileLoaderMethodName = latestJSBundleFile.toLowerCase().startsWith("assets://")
? "createAssetLoader" : "createFileLoader";
Copy link
Contributor

@AndrewJack AndrewJack May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid assigning inside the loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AndrewJack - thanks for pointing at this, added commit to fix this.

if (method.getName().equals(createFileLoaderMethodName)) {
createFileLoaderMethod = method;
break;
}
Expand All @@ -125,7 +127,7 @@ private void setJSBundle(ReactInstanceManager instanceManager, String latestJSBu
// RN >= v0.34
latestJSBundleLoader = createFileLoaderMethod.invoke(jsBundleLoaderClass, latestJSBundleFile);
} else if (numParameters == 2) {
// RN >= v0.31 && RN < v0.34
// RN >= v0.31 && RN < v0.34 or AssetLoader instance
latestJSBundleLoader = createFileLoaderMethod.invoke(jsBundleLoaderClass, getReactApplicationContext(), latestJSBundleFile);
} else {
throw new NoSuchMethodException("Could not find a recognized 'createFileLoader' method");
Expand Down Expand Up @@ -319,7 +321,7 @@ protected Void doInBackground(Void... params) {
JSONObject currentPackage = mUpdateManager.getCurrentPackage();

if (currentPackage == null) {
promise.resolve("");
promise.resolve(null);
return null;
}

Expand All @@ -333,14 +335,14 @@ protected Void doInBackground(Void... params) {
if (updateState == CodePushUpdateState.PENDING.getValue() && !currentUpdateIsPending) {
// The caller wanted a pending update
// but there isn't currently one.
promise.resolve("");
promise.resolve(null);
} else if (updateState == CodePushUpdateState.RUNNING.getValue() && currentUpdateIsPending) {
// The caller wants the running update, but the current
// one is pending, so we need to grab the previous.
JSONObject previousPackage = mUpdateManager.getPreviousPackage();

if (previousPackage == null) {
promise.resolve("");
promise.resolve(null);
return null;
}

Expand Down