Skip to content

Commit 7a327d9

Browse files
Refactor accessory show methods for DevLoading
Summary: Changelog: [Internal][Changed] - In order to make Dev Loading View cross platform, refactoring the accessary show methods. Reviewed By: cortinico Differential Revision: D41029102 fbshipit-source-id: 475949548fe98217e61d6cf64accbbdc0fb0f1c5
1 parent 3d9a15d commit 7a327d9

File tree

2 files changed

+23
-32
lines changed

2 files changed

+23
-32
lines changed

ReactAndroid/src/main/java/com/facebook/react/devsupport/DevLoadingViewController.java

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
import com.facebook.react.R;
2323
import com.facebook.react.bridge.UiThreadUtil;
2424
import com.facebook.react.common.ReactConstants;
25-
import java.net.MalformedURLException;
26-
import java.net.URL;
2725
import java.util.Locale;
2826

2927
/** Controller to display loading messages on top of the screen. All methods are thread safe. */
@@ -55,34 +53,6 @@ public void run() {
5553
});
5654
}
5755

58-
public void showForUrl(String url) {
59-
Context context = getContext();
60-
if (context == null) {
61-
return;
62-
}
63-
64-
URL parsedURL;
65-
try {
66-
parsedURL = new URL(url);
67-
} catch (MalformedURLException e) {
68-
FLog.e(ReactConstants.TAG, "Bundle url format is invalid. \n\n" + e.toString());
69-
return;
70-
}
71-
72-
int port = parsedURL.getPort() != -1 ? parsedURL.getPort() : parsedURL.getDefaultPort();
73-
showMessage(
74-
context.getString(R.string.catalyst_loading_from_url, parsedURL.getHost() + ":" + port));
75-
}
76-
77-
public void showForRemoteJSEnabled() {
78-
Context context = getContext();
79-
if (context == null) {
80-
return;
81-
}
82-
83-
showMessage(context.getString(R.string.catalyst_debug_connecting));
84-
}
85-
8656
public void updateProgress(
8757
final @Nullable String status, final @Nullable Integer done, final @Nullable Integer total) {
8858
if (!sEnabled) {

ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,13 +752,34 @@ protected ReactInstanceDevHelper getReactInstanceDevHelper() {
752752

753753
@UiThread
754754
private void showDevLoadingViewForUrl(String bundleUrl) {
755-
mDevLoadingViewController.showForUrl(bundleUrl);
755+
if (mApplicationContext == null) {
756+
return;
757+
}
758+
759+
URL parsedURL;
760+
761+
try {
762+
parsedURL = new URL(bundleUrl);
763+
} catch (MalformedURLException e) {
764+
FLog.e(ReactConstants.TAG, "Bundle url format is invalid. \n\n" + e.toString());
765+
return;
766+
}
767+
768+
int port = parsedURL.getPort() != -1 ? parsedURL.getPort() : parsedURL.getDefaultPort();
769+
mDevLoadingViewController.showMessage(
770+
mApplicationContext.getString(
771+
R.string.catalyst_loading_from_url, parsedURL.getHost() + ":" + port));
756772
mDevLoadingViewVisible = true;
757773
}
758774

759775
@UiThread
760776
protected void showDevLoadingViewForRemoteJSEnabled() {
761-
mDevLoadingViewController.showForRemoteJSEnabled();
777+
if (mApplicationContext == null) {
778+
return;
779+
}
780+
781+
mDevLoadingViewController.showMessage(
782+
mApplicationContext.getString(R.string.catalyst_debug_connecting));
762783
mDevLoadingViewVisible = true;
763784
}
764785

0 commit comments

Comments
 (0)