Add support for RCTImageView in FlatShadowHierarchyManager

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
This commit is contained in:
Denis Koroskin
2015-12-11 22:44:38 -08:00
committed by Ahmed El-Helw
parent dfe5f9f762
commit 760422525e
14 changed files with 784 additions and 14 deletions

View File

@@ -20,7 +20,9 @@ package com.facebook.react.flat;
private final FlatUIViewOperationQueue mOperationsQueue;
private final ElementsList<DrawCommand> mDrawCommands =
new ElementsList(DrawCommand.EMPTY_ARRAY);
new ElementsList<>(DrawCommand.EMPTY_ARRAY);
private final ElementsList<AttachDetachListener> mAttachDetachListeners =
new ElementsList<>(AttachDetachListener.EMPTY_ARRAY);
/* package */ StateBuilder(FlatUIViewOperationQueue operationsQueue) {
mOperationsQueue = operationsQueue;
@@ -41,6 +43,10 @@ package com.facebook.react.flat;
mDrawCommands.add(drawCommand);
}
/* package */ void addAttachDetachListener(AttachDetachListener listener) {
mAttachDetachListeners.add(listener);
}
/**
* Updates boundaries of a View that a give nodes maps to.
*/
@@ -76,15 +82,25 @@ package com.facebook.react.flat;
float width,
float height) {
mDrawCommands.start(node.getDrawCommands());
mAttachDetachListeners.start(node.getAttachDetachListeners());
collectStateRecursively(node, 0, 0, width, height);
boolean shouldUpdateMountState = false;
final DrawCommand[] drawCommands = mDrawCommands.finish();
if (drawCommands != null) {
// DrawCommands changed, need to re-mount them and re-draw the View.
shouldUpdateMountState = true;
node.setDrawCommands(drawCommands);
}
mOperationsQueue.enqueueUpdateMountState(tag, drawCommands);
final AttachDetachListener[] listeners = mAttachDetachListeners.finish();
if (listeners != null) {
shouldUpdateMountState = true;
node.setAttachDetachListeners(listeners);
}
if (shouldUpdateMountState) {
mOperationsQueue.enqueueUpdateMountState(tag, drawCommands, listeners);
}
}