diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java index 5ac7ebc90..cb0f509cf 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java @@ -222,16 +222,19 @@ public class DevServerHelper { return String.format(Locale.US, RESOURCE_URL_FORMAT, host, resourcePath); } + public String getDevServerBundleURL(final String jsModulePath) { + return createBundleURL( + getDebugServerHost(), + jsModulePath, + getDevMode(), + getHMR(), + getJSMinifyMode()); + } + public void downloadBundleFromURL( final BundleDownloadCallback callback, - final String jsModulePath, - final File outputFile) { - final String bundleURL = createBundleURL( - getDebugServerHost(), - jsModulePath, - getDevMode(), - getHMR(), - getJSMinifyMode()); + final File outputFile, + final String bundleURL) { final Request request = new Request.Builder() .url(bundleURL) .build(); diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManager.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManager.java index 26623ff45..a0e3f6d06 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManager.java @@ -45,6 +45,7 @@ public interface DevSupportManager extends NativeModuleCallExceptionHandler { boolean hasUpToDateJSBundleInCache(); void reloadSettings(); void handleReloadJS(); + void reloadJSFromServer(final String bundleURL); void isPackagerRunning(DevServerHelper.PackagerStatusCallback callback); @Nullable File downloadBundleResourceFromUrlSync( final String resourceURL, diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java index 739116ede..bb163b31f 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java @@ -635,18 +635,12 @@ public class DevSupportManagerImpl implements DevSupportManager, PackagerCommand mRedBoxDialog.dismiss(); } - AlertDialog dialog = new AlertDialog.Builder(mApplicationContext) - .setTitle(R.string.catalyst_jsload_title) - .setMessage(mApplicationContext.getString( - mDevSettings.isRemoteJSDebugEnabled() ? R.string.catalyst_remotedbg_message : R.string.catalyst_jsload_message)) - .create(); - dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); - dialog.show(); - if (mDevSettings.isRemoteJSDebugEnabled()) { - reloadJSInProxyMode(dialog); + reloadJSInProxyMode(showProgressDialog()); } else { - reloadJSFromServer(dialog); + String bundleURL = + mDevServerHelper.getDevServerBundleURL(Assertions.assertNotNull(mJSAppBundleName)); + reloadJSFromServer(bundleURL); } } @@ -741,7 +735,22 @@ public class DevSupportManagerImpl implements DevSupportManager, PackagerCommand }; } - private void reloadJSFromServer(final AlertDialog progressDialog) { + private AlertDialog showProgressDialog() { + AlertDialog dialog = new AlertDialog.Builder(mApplicationContext) + .setTitle(R.string.catalyst_jsload_title) + .setMessage(mApplicationContext.getString( + mDevSettings.isRemoteJSDebugEnabled() ? + R.string.catalyst_remotedbg_message : + R.string.catalyst_jsload_message)) + .create(); + dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); + dialog.show(); + return dialog; + } + + public void reloadJSFromServer(final String bundleURL) { + final AlertDialog progressDialog = showProgressDialog(); + mDevServerHelper.downloadBundleFromURL( new DevServerHelper.BundleDownloadCallback() { @Override @@ -776,8 +785,8 @@ public class DevSupportManagerImpl implements DevSupportManager, PackagerCommand }); } }, - Assertions.assertNotNull(mJSAppBundleName), - mJSBundleTempFile); + mJSBundleTempFile, + bundleURL); progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DisabledDevSupportManager.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DisabledDevSupportManager.java index 3844d5223..f5592d0f1 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DisabledDevSupportManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DisabledDevSupportManager.java @@ -126,6 +126,11 @@ public class DisabledDevSupportManager implements DevSupportManager { } + @Override + public void reloadJSFromServer(String bundleURL) { + + } + @Override public void isPackagerRunning(DevServerHelper.PackagerStatusCallback callback) {