Files
react-native/ReactAndroid/src/main/java/com/facebook/react/flat/FlatARTSurfaceViewManager.java
T
Seth Kirby c8bb422882 Fix Nodes not having correct view managers externally
Reviewed By: ahmedre

Differential Revision: D4927963

fbshipit-source-id: f4993aa45f6313e814d03141f828d37eafade059
2017-04-27 15:50:15 -07:00

63 lines
1.9 KiB
Java

/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package com.facebook.react.flat;
import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.views.art.ARTSurfaceView;
import com.facebook.yoga.YogaMeasureFunction;
import com.facebook.yoga.YogaMeasureMode;
import com.facebook.yoga.YogaNode;
public class FlatARTSurfaceViewManager extends
BaseViewManager<ARTSurfaceView, FlatARTSurfaceViewShadowNode> {
/* package */ static final String REACT_CLASS = "ARTSurfaceView";
private static final YogaMeasureFunction MEASURE_FUNCTION = new YogaMeasureFunction() {
@Override
public long measure(
YogaNode node,
float width,
YogaMeasureMode widthMode,
float height,
YogaMeasureMode heightMode) {
throw new IllegalStateException("SurfaceView should have explicit width and height set");
}
};
@Override
public String getName() {
return REACT_CLASS;
}
@Override
public FlatARTSurfaceViewShadowNode createShadowNodeInstance() {
FlatARTSurfaceViewShadowNode node = new FlatARTSurfaceViewShadowNode();
node.setMeasureFunction(MEASURE_FUNCTION);
return node;
}
@Override
public Class<FlatARTSurfaceViewShadowNode> getShadowNodeClass() {
return FlatARTSurfaceViewShadowNode.class;
}
@Override
protected ARTSurfaceView createViewInstance(ThemedReactContext reactContext) {
return new ARTSurfaceView(reactContext);
}
@Override
public void updateExtraData(ARTSurfaceView root, Object extraData) {
root.setSurfaceTextureListener((FlatARTSurfaceViewShadowNode) extraData);
}
}