Skip to content

Commit

Permalink
Abstracting Activity logic from Dev Loading View (#35256)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #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
  • Loading branch information
arushikesarwani94 authored and facebook-github-bot committed Nov 11, 2022
1 parent 29caed2 commit 1a4fa92
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -39,6 +40,7 @@ public DevLoadingViewController(ReactInstanceDevHelper reactInstanceManagerHelpe
mReactInstanceManagerHelper = reactInstanceManagerHelper;
}

@Override
public void showMessage(final String message) {
if (!sEnabled) {
return;
Expand All @@ -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) {
Expand All @@ -77,6 +80,7 @@ public void run() {
});
}

@Override
public void hide() {
if (!sEnabled) {
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}

0 comments on commit 1a4fa92

Please sign in to comment.