diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/common/BUCK b/ReactAndroid/src/main/java/com/facebook/react/uimanager/common/BUCK index 5c4a5b26df6..08230b0a0be 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/common/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/common/BUCK @@ -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", ], diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/common/ViewType.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/common/ViewType.java new file mode 100644 index 00000000000..66e4fdbecd4 --- /dev/null +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/common/ViewType.java @@ -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; +} diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/common/ViewUtil.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/common/ViewUtil.java new file mode 100644 index 00000000000..cc7a3ddcbd0 --- /dev/null +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/common/ViewUtil.java @@ -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; + } + +}