mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-15 09:27:05 +08:00
Create UIManager interface and extract common classes in uimanager/common
Reviewed By: achen1 Differential Revision: D7102674 fbshipit-source-id: e14b6782ad102ec1c3d37988df4bbd4190511f09
This commit is contained in:
committed by
Facebook Github Bot
parent
b181b7797f
commit
6b45fb2cb1
@@ -0,0 +1,12 @@
|
||||
load("//ReactNative:DEFS.bzl", "rn_android_library", "react_native_dep", "react_native_target")
|
||||
|
||||
rn_android_library(
|
||||
name = "common",
|
||||
srcs = glob(["*.java"]),
|
||||
visibility = [
|
||||
"PUBLIC",
|
||||
],
|
||||
deps = [
|
||||
react_native_dep("third-party/java/jsr-305:jsr-305"),
|
||||
],
|
||||
)
|
||||
@@ -0,0 +1,17 @@
|
||||
// Copyright 2004-present Facebook. All Rights Reserved.
|
||||
|
||||
package com.facebook.react.uimanager.common;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
/**
|
||||
* Interface for a {@link View} subclass that provides the width and height measure specs from its
|
||||
* measure pass. This is currently used to re-measure the root view by reusing the specs for yoga
|
||||
* layout calculations.
|
||||
*/
|
||||
public interface MeasureSpecProvider {
|
||||
|
||||
int getWidthMeasureSpec();
|
||||
|
||||
int getHeightMeasureSpec();
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* Copyright (c) 2015-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 javax.annotation.Nullable;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
/**
|
||||
* Subclass of {@link FrameLayout} that allows registering for size change events. The main purpose
|
||||
* for this class is to hide complexity of {@link ReactRootView} from the code under
|
||||
* {@link com.facebook.react.uimanager} package.
|
||||
*/
|
||||
public class SizeMonitoringFrameLayout extends FrameLayout {
|
||||
|
||||
public static interface OnSizeChangedListener {
|
||||
void onSizeChanged(int width, int height, int oldWidth, int oldHeight);
|
||||
}
|
||||
|
||||
private @Nullable OnSizeChangedListener mOnSizeChangedListener;
|
||||
|
||||
public SizeMonitoringFrameLayout(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public SizeMonitoringFrameLayout(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public SizeMonitoringFrameLayout(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
public void setOnSizeChangedListener(OnSizeChangedListener onSizeChangedListener) {
|
||||
mOnSizeChangedListener = onSizeChangedListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||
super.onSizeChanged(w, h, oldw, oldh);
|
||||
|
||||
if (mOnSizeChangedListener != null) {
|
||||
mOnSizeChangedListener.onSizeChanged(w, h, oldw, oldh);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user