Introducing ViewType in native code
Reviewed By: achen1 Differential Revision: D7729477 fbshipit-source-id: e8d1af87489522c4ae8b52b6a9e4c0a680abf4f6
This commit is contained in:
parent
6b07602915
commit
16a5324ca6
|
@ -3,6 +3,10 @@ load("//ReactNative:DEFS.bzl", "rn_android_library", "react_native_dep", "react_
|
|||
rn_android_library(
|
||||
name = "common",
|
||||
srcs = glob(["*.java"]),
|
||||
provided_deps = [
|
||||
react_native_dep("third-party/android/support/v4:lib-support-v4"),
|
||||
react_native_dep("third-party/android/support-annotations:android-support-annotations"),
|
||||
],
|
||||
visibility = [
|
||||
"PUBLIC",
|
||||
],
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
*
|
||||
* 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.uimanager.common;
|
||||
|
||||
import static com.facebook.react.uimanager.common.ViewType.FABRIC;
|
||||
import static com.facebook.react.uimanager.common.ViewType.PAPER;
|
||||
import static java.lang.annotation.RetentionPolicy.SOURCE;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import android.support.annotation.IntDef;
|
||||
|
||||
@Retention(SOURCE)
|
||||
@IntDef({PAPER, FABRIC})
|
||||
public @interface ViewType {
|
||||
int PAPER = 1;
|
||||
int FABRIC = 2;
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
*
|
||||
* 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.uimanager.common;
|
||||
|
||||
import static com.facebook.react.uimanager.common.ViewType.FABRIC;
|
||||
import static com.facebook.react.uimanager.common.ViewType.PAPER;
|
||||
|
||||
public class ViewUtil {
|
||||
|
||||
/**
|
||||
* Counter for uniquely identifying views.
|
||||
* - % 10 === 1 means it is a rootTag.
|
||||
* - % 2 === 0 means it is a Fabric tag.
|
||||
* See https://github.com/facebook/react/pull/12587
|
||||
*
|
||||
* @param reactTag {@link }
|
||||
*/
|
||||
@ViewType
|
||||
public static int getViewType(int reactTag) {
|
||||
if (reactTag % 2 == 0) return FABRIC;
|
||||
return PAPER;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue