Skip to content

Commit

Permalink
Merge branch 'main' into dp_dimension
Browse files Browse the repository at this point in the history
  • Loading branch information
open-hippy authored Nov 16, 2023
2 parents f4e2a12 + 1d82566 commit 78e4c87
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import com.tencent.renderer.NativeRender;
import com.tencent.renderer.NativeRenderException;
import com.tencent.renderer.NativeRendererManager;
import com.tencent.renderer.component.text.TextRenderSupplier;
import com.tencent.renderer.node.TextVirtualNode;
import com.tencent.renderer.utils.ArrayUtils;

Expand Down Expand Up @@ -87,14 +88,14 @@ protected View createViewImpl(Context context) {
protected void updateExtra(@NonNull View view, Object object) {
super.updateExtra(view, object);

// if (object instanceof TextExtra) {
// TextExtra textExtra = (TextExtra) object;
// HippyTextInput hippyTextInput = (HippyTextInput) view;
// hippyTextInput.setPadding((int) Math.ceil(textExtra.mLeftPadding),
// (int) Math.ceil(textExtra.mTopPadding),
// (int) Math.ceil(textExtra.mRightPadding),
// (int) Math.ceil(textExtra.mBottomPadding));
// }
if (object instanceof TextRenderSupplier) {
TextRenderSupplier supplier = (TextRenderSupplier) object;
HippyTextInput hippyTextInput = (HippyTextInput) view;
hippyTextInput.setPadding((int) Math.ceil(supplier.leftPadding),
(int) Math.ceil(supplier.topPadding),
(int) Math.ceil(supplier.rightPadding),
(int) Math.ceil(supplier.bottomPadding));
}
}

@HippyControllerProps(name = NodeProps.FONT_SIZE, defaultType = HippyControllerProps.NUMBER, defaultNumber = 14)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ public void updateExtra(@Nullable Object object) {
component.setTextLayout(object);
setNodeFlag(FLAG_UPDATE_EXTRA);
}
mExtra = object;
}

public boolean isDeleted() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public boolean updateEventListener(int rootId, int nodeId, @NonNull Map<String,
public TextRenderSupplier updateLayout(int rootId, int nodeId, float width,
Map<String, Object> layoutInfo) {
VirtualNode node = getVirtualNode(rootId, nodeId);
if (!(node instanceof TextVirtualNode) || node.mParent != null) {
if (!(node instanceof TextVirtualNode || node instanceof TextInputVirtualNode) || node.mParent != null) {
return null;
}
float leftPadding = 0;
Expand All @@ -159,12 +159,17 @@ public TextRenderSupplier updateLayout(int rootId, int nodeId, float width,
// just ignore this exception
LogUtils.w(TAG, "VirtualNode updateLayout get padding exception: " + e.getMessage());
}
Layout layout = ((TextVirtualNode) node)
.createLayout((width - leftPadding - rightPadding), FlexMeasureMode.EXACTLY);
// Layout has update here, not need to rebuild in end batch, so remove node ref from mUpdateNodes.
List<VirtualNode> updateNodes = mUpdateNodes.get(rootId);
if (updateNodes != null) {
updateNodes.remove(node);
final Layout layout;
if (node instanceof TextVirtualNode) {
layout = ((TextVirtualNode) node)
.createLayout((width - leftPadding - rightPadding), FlexMeasureMode.EXACTLY);
// Layout has update here, not need to rebuild in end batch, so remove node ref from mUpdateNodes.
List<VirtualNode> updateNodes = mUpdateNodes.get(rootId);
if (updateNodes != null) {
updateNodes.remove(node);
}
} else {
layout = null;
}
return new TextRenderSupplier(layout, leftPadding, topPadding,
rightPadding, bottomPadding);
Expand Down

0 comments on commit 78e4c87

Please sign in to comment.