mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Introduce setDisplayMode method in SurfaceHandler
Summary: This diff introduces the new setDisplayMode java method in SurfaceHandler classes changelog: [internal] internal Reviewed By: JoshuaGross Differential Revision: D27607585 fbshipit-source-id: aac0def4136cf70e99ef7b20eba85e3e975b72d9
This commit is contained in:
committed by
Facebook GitHub Bot
parent
e7b52d7b0b
commit
84c70b2a7f
@@ -45,4 +45,6 @@ public interface SurfaceHandler {
|
||||
boolean doLeftAndRightSwapInRTL,
|
||||
boolean isRTL,
|
||||
float pixelDensity);
|
||||
|
||||
void setMountable(boolean mountable);
|
||||
}
|
||||
|
||||
@@ -10,9 +10,12 @@ package com.facebook.react.fabric;
|
||||
import static com.facebook.react.fabric.mounting.LayoutMetricsConversions.getMaxSize;
|
||||
import static com.facebook.react.fabric.mounting.LayoutMetricsConversions.getMinSize;
|
||||
|
||||
import androidx.annotation.IntDef;
|
||||
import com.facebook.jni.HybridData;
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
import com.facebook.react.bridge.NativeMap;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
public class SurfaceHandlerBinding implements SurfaceHandler {
|
||||
static {
|
||||
@@ -21,6 +24,15 @@ public class SurfaceHandlerBinding implements SurfaceHandler {
|
||||
|
||||
private static final int NO_SURFACE_ID = 0;
|
||||
|
||||
/* Keep in sync with SurfaceHandler.cpp */
|
||||
public static final int DISPLAY_MODE_VISIBLE = 0;
|
||||
public static final int DISPLAY_MODE_SUSPENDED = 1;
|
||||
public static final int DISPLAY_MODE_HIDDEN = 2;
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef({DISPLAY_MODE_VISIBLE, DISPLAY_MODE_SUSPENDED, DISPLAY_MODE_HIDDEN})
|
||||
public @interface DisplayModeTypeDef {}
|
||||
|
||||
@DoNotStrip private final HybridData mHybridData;
|
||||
|
||||
private static native HybridData initHybrid(int surfaceId, String moduleName);
|
||||
@@ -109,4 +121,11 @@ public class SurfaceHandlerBinding implements SurfaceHandler {
|
||||
}
|
||||
|
||||
private native void setPropsNative(NativeMap props);
|
||||
|
||||
@Override
|
||||
public void setMountable(boolean mountable) {
|
||||
setDisplayModeNative(mountable ? DISPLAY_MODE_VISIBLE : DISPLAY_MODE_SUSPENDED);
|
||||
}
|
||||
|
||||
private native void setDisplayModeNative(@DisplayModeTypeDef int mode);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,11 @@ SurfaceHandlerBinding::SurfaceHandlerBinding(
|
||||
std::string const &moduleName)
|
||||
: surfaceHandler_(moduleName, surfaceId) {}
|
||||
|
||||
void SurfaceHandlerBinding::setDisplayMode(jint mode) {
|
||||
surfaceHandler_.setDisplayMode(
|
||||
static_cast<SurfaceHandler::DisplayMode>(mode));
|
||||
}
|
||||
|
||||
void SurfaceHandlerBinding::start() {
|
||||
std::unique_lock<better::shared_mutex> lock(lifecycleMutex_);
|
||||
|
||||
@@ -116,6 +121,8 @@ void SurfaceHandlerBinding::registerNatives() {
|
||||
"setLayoutConstraintsNative",
|
||||
SurfaceHandlerBinding::setLayoutConstraints),
|
||||
makeNativeMethod("setPropsNative", SurfaceHandlerBinding::setProps),
|
||||
makeNativeMethod(
|
||||
"setDisplayModeNative", SurfaceHandlerBinding::setDisplayMode),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@ class SurfaceHandlerBinding : public jni::HybridClass<SurfaceHandlerBinding> {
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
void setDisplayMode(jint mode);
|
||||
|
||||
void registerScheduler(std::shared_ptr<Scheduler> scheduler);
|
||||
void unregisterScheduler(std::shared_ptr<Scheduler> scheduler);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user