From 1a4fa92b253aeb70162322e9d4135fb34901dcf1 Mon Sep 17 00:00:00 2001 From: Arushi Kesarwani Date: Fri, 11 Nov 2022 05:12:02 -0800 Subject: [PATCH] Abstracting Activity logic from Dev Loading View (#35256) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/35256 Changelog: [General][Added] - Making Dev Loading View cross platform by abstracting out the activity/context logic from the controller in a polymorph class. Reviewed By: rshest Differential Revision: D40908923 fbshipit-source-id: db8e94f8ded5ffe0deeb88335cd7f3d1bf87243a --- .../devsupport/DevLoadingViewController.java | 6 +++++- .../interfaces/DevLoadingViewManager.java | 21 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 ReactAndroid/src/main/java/com/facebook/react/devsupport/interfaces/DevLoadingViewManager.java diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevLoadingViewController.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevLoadingViewController.java index 9697c4da7e8132..95fafd3c5e2b65 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevLoadingViewController.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevLoadingViewController.java @@ -22,10 +22,11 @@ import com.facebook.react.R; import com.facebook.react.bridge.UiThreadUtil; import com.facebook.react.common.ReactConstants; +import com.facebook.react.devsupport.interfaces.DevLoadingViewManager; import java.util.Locale; /** Controller to display loading messages on top of the screen. All methods are thread safe. */ -public class DevLoadingViewController { +public class DevLoadingViewController implements DevLoadingViewManager { private static boolean sEnabled = true; private final ReactInstanceDevHelper mReactInstanceManagerHelper; private @Nullable TextView mDevLoadingView; @@ -39,6 +40,7 @@ public DevLoadingViewController(ReactInstanceDevHelper reactInstanceManagerHelpe mReactInstanceManagerHelper = reactInstanceManagerHelper; } + @Override public void showMessage(final String message) { if (!sEnabled) { return; @@ -53,6 +55,7 @@ public void run() { }); } + @Override public void updateProgress( final @Nullable String status, final @Nullable Integer done, final @Nullable Integer total) { if (!sEnabled) { @@ -77,6 +80,7 @@ public void run() { }); } + @Override public void hide() { if (!sEnabled) { return; diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/interfaces/DevLoadingViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/interfaces/DevLoadingViewManager.java new file mode 100644 index 00000000000000..5b51c4f89258a3 --- /dev/null +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/interfaces/DevLoadingViewManager.java @@ -0,0 +1,21 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +package com.facebook.react.devsupport.interfaces; + +import androidx.annotation.Nullable; + +/** Interface to display loading messages on top of the screen. */ +public interface DevLoadingViewManager { + + void showMessage(final String message); + + void updateProgress( + final @Nullable String status, final @Nullable Integer done, final @Nullable Integer total); + + void hide(); +}