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
This commit is contained in:
Arushi Kesarwani
2022-11-11 05:12:02 -08:00
committed by Facebook GitHub Bot
parent 29caed22cc
commit 1a4fa92b25
2 changed files with 26 additions and 1 deletions
@@ -22,10 +22,11 @@ import com.facebook.common.logging.FLog;
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 class DevLoadingViewController {
mReactInstanceManagerHelper = reactInstanceManagerHelper;
}
@Override
public void showMessage(final String message) {
if (!sEnabled) {
return;
@@ -53,6 +55,7 @@ public class DevLoadingViewController {
});
}
@Override
public void updateProgress(
final @Nullable String status, final @Nullable Integer done, final @Nullable Integer total) {
if (!sEnabled) {
@@ -77,6 +80,7 @@ public class DevLoadingViewController {
});
}
@Override
public void hide() {
if (!sEnabled) {
return;
@@ -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();
}