-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding native implementation for Dev Loading View for Android (#35743)
Summary: Pull Request resolved: #35743 Changelog: [Android][Added] - For supporting Dev Loading View across multiple platforms, altering the javascript implementation of Loading view of android to also rely on native implementation as iOS instead of Toast, thereby unifying both platforms Reviewed By: rshest Differential Revision: D42258041 fbshipit-source-id: 1be56c1e5696b1024ba09a0aa11da96e0a08f210
- Loading branch information
1 parent
afd954e
commit 068a208
Showing
3 changed files
with
104 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
ReactAndroid/src/main/java/com/facebook/react/modules/devloading/BUCK
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_root_target", "react_native_target", "rn_android_library") | ||
|
||
rn_android_library( | ||
name = "devloading", | ||
srcs = glob(["**/*.java"]), | ||
autoglob = False, | ||
labels = [ | ||
"pfh:ReactNative_CommonInfrastructurePlaceholder", | ||
], | ||
language = "JAVA", | ||
visibility = [ | ||
"PUBLIC", | ||
], | ||
deps = [ | ||
react_native_dep("third-party/java/infer-annotations:infer-annotations"), | ||
react_native_dep("third-party/java/jsr-305:jsr-305"), | ||
react_native_target("java/com/facebook/react/bridge:bridge"), | ||
react_native_target("java/com/facebook/react/common:common"), | ||
react_native_target("java/com/facebook/react/module/annotations:annotations"), | ||
], | ||
exported_deps = [react_native_root_target(":FBReactNativeSpec")], | ||
) |
48 changes: 48 additions & 0 deletions
48
ReactAndroid/src/main/java/com/facebook/react/modules/devloading/DevLoadingModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* 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.modules.devloading; | ||
|
||
import android.util.Log; | ||
import com.facebook.fbreact.specs.NativeDevLoadingViewSpec; | ||
import com.facebook.react.bridge.NativeModule; | ||
import com.facebook.react.bridge.ReactApplicationContext; | ||
import com.facebook.react.bridge.UiThreadUtil; | ||
import com.facebook.react.module.annotations.ReactModule; | ||
|
||
/** {@link NativeModule} that allows JS to show dev loading view. */ | ||
@ReactModule(name = NativeDevLoadingViewSpec.NAME) | ||
public class DevLoadingModule extends NativeDevLoadingViewSpec { | ||
|
||
public DevLoadingModule(ReactApplicationContext reactContext) { | ||
super(reactContext); | ||
} | ||
|
||
@Override | ||
public void showMessage(final String message, final Double color, final Double backgroundColor) { | ||
|
||
UiThreadUtil.runOnUiThread( | ||
new Runnable() { | ||
@Override | ||
public void run() { | ||
Log.w(NAME, "Showing Message in DevLoadingModule java."); | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public void hide() { | ||
|
||
UiThreadUtil.runOnUiThread( | ||
new Runnable() { | ||
@Override | ||
public void run() { | ||
Log.w(NAME, "Hiding Message in DevLoadingModule java."); | ||
} | ||
}); | ||
} | ||
} |