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

Commit 2f1afd6

Browse files
author
max-mironov
committed
Code refactoring: moved variable assignment out of loop
1 parent e122824 commit 2f1afd6

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ private void setJSBundle(ReactInstanceManager instanceManager, String latestJSBu
105105
Field bundleLoaderField = instanceManager.getClass().getDeclaredField("mBundleLoader");
106106
Class<?> jsBundleLoaderClass = Class.forName("com.facebook.react.cxxbridge.JSBundleLoader");
107107
Method createFileLoaderMethod = null;
108+
String createFileLoaderMethodName = latestJSBundleFile.toLowerCase().startsWith("assets://")
109+
? "createAssetLoader" : "createFileLoader";
108110

109111
Method[] methods = jsBundleLoaderClass.getDeclaredMethods();
110-
for (Method method : methods) {
111-
String createFileLoaderMethodName = latestJSBundleFile.toLowerCase().startsWith("assets://")
112-
? "createAssetLoader" : "createFileLoader";
112+
for (Method method : methods) {
113113
if (method.getName().equals(createFileLoaderMethodName)) {
114114
createFileLoaderMethod = method;
115115
break;
@@ -321,7 +321,7 @@ protected Void doInBackground(Void... params) {
321321
JSONObject currentPackage = mUpdateManager.getCurrentPackage();
322322

323323
if (currentPackage == null) {
324-
promise.resolve(null);
324+
promise.resolve("");
325325
return null;
326326
}
327327

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

344344
if (previousPackage == null) {
345-
promise.resolve(null);
345+
promise.resolve("");
346346
return null;
347347
}
348348

0 commit comments

Comments
 (0)