mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
760422525e
Summary: @public This patch adds basic support for RCTImageView (only 'src', 'tintColor' and 'resizeMode' properties are supported for now), and a concept of AttachDetachListener that is required to support it to FlatUIImplementations. Reviewed By: sriramramani Differential Revision: D2564389
102 lines
3.1 KiB
Java
102 lines
3.1 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 javax.annotation.Nullable;
|
|
|
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
import com.facebook.react.uimanager.UIViewOperationQueue;
|
|
|
|
/**
|
|
* FlatUIViewOperationQueue extends {@link UIViewOperationQueue} to add
|
|
* FlatUIImplementation-specific methods that need to run in UI thread.
|
|
*/
|
|
/* package */ final class FlatUIViewOperationQueue extends UIViewOperationQueue {
|
|
|
|
private final FlatNativeViewHierarchyManager mNativeViewHierarchyManager;
|
|
|
|
/**
|
|
* UIOperation that updates DrawCommands for a View defined by reactTag.
|
|
*/
|
|
private final class UpdateMountState implements UIOperation {
|
|
|
|
private final int mReactTag;
|
|
private final @Nullable DrawCommand[] mDrawCommands;
|
|
private final @Nullable AttachDetachListener[] mAttachDetachListeners;
|
|
|
|
private UpdateMountState(
|
|
int reactTag,
|
|
@Nullable DrawCommand[] drawCommands,
|
|
@Nullable AttachDetachListener[] listeners) {
|
|
mReactTag = reactTag;
|
|
mDrawCommands = drawCommands;
|
|
mAttachDetachListeners = listeners;
|
|
}
|
|
|
|
@Override
|
|
public void execute() {
|
|
mNativeViewHierarchyManager.updateMountState(
|
|
mReactTag,
|
|
mDrawCommands,
|
|
mAttachDetachListeners);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* UIOperation that updates View bounds for a View defined by reactTag.
|
|
*/
|
|
private final class UpdateViewBounds implements UIOperation {
|
|
|
|
private final int mReactTag;
|
|
private final int mLeft;
|
|
private final int mTop;
|
|
private final int mRight;
|
|
private final int mBottom;
|
|
|
|
private UpdateViewBounds(int reactTag, int left, int top, int right, int bottom) {
|
|
mReactTag = reactTag;
|
|
mLeft = left;
|
|
mTop = top;
|
|
mRight = right;
|
|
mBottom = bottom;
|
|
}
|
|
|
|
@Override
|
|
public void execute() {
|
|
mNativeViewHierarchyManager.updateViewBounds(mReactTag, mLeft, mTop, mRight, mBottom);
|
|
}
|
|
}
|
|
|
|
public FlatUIViewOperationQueue(
|
|
ReactApplicationContext reactContext,
|
|
FlatNativeViewHierarchyManager nativeViewHierarchyManager) {
|
|
super(reactContext, nativeViewHierarchyManager);
|
|
|
|
mNativeViewHierarchyManager = nativeViewHierarchyManager;
|
|
}
|
|
|
|
/**
|
|
* Enqueues a new UIOperation that will update DrawCommands for a View defined by reactTag.
|
|
*/
|
|
public void enqueueUpdateMountState(
|
|
int reactTag,
|
|
@Nullable DrawCommand[] drawCommands,
|
|
@Nullable AttachDetachListener[] listeners) {
|
|
enqueueUIOperation(new UpdateMountState(reactTag, drawCommands, listeners));
|
|
}
|
|
|
|
/**
|
|
* Enqueues a new UIOperation that will update View bounds for a View defined by reactTag.
|
|
*/
|
|
public void enqueueUpdateViewBounds(int reactTag, int left, int top, int right, int bottom) {
|
|
enqueueUIOperation(new UpdateViewBounds(reactTag, left, top, right, bottom));
|
|
}
|
|
}
|