From 12368f269a3c3704fb434c97467b0de105649180 Mon Sep 17 00:00:00 2001 From: maxli Date: Thu, 10 Aug 2023 16:17:17 +0800 Subject: [PATCH] fix(android): expand cache hit range --- .../main/java/com/tencent/renderer/node/TextVirtualNode.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/renderer/native/android/src/main/java/com/tencent/renderer/node/TextVirtualNode.java b/renderer/native/android/src/main/java/com/tencent/renderer/node/TextVirtualNode.java index bfecada97ac..4d434f852c4 100644 --- a/renderer/native/android/src/main/java/com/tencent/renderer/node/TextVirtualNode.java +++ b/renderer/native/android/src/main/java/com/tencent/renderer/node/TextVirtualNode.java @@ -452,7 +452,8 @@ protected Layout createLayout(final float width, final FlexMeasureMode widthMode if (mSpanned == null || mDirty) { mSpanned = createSpan(true); mDirty = false; - } else if (mLayout != null && width >= mLastLayoutWidth && width <= (mLastLayoutWidth + 1)) { + } else if (mLayout != null && width >= (mLastLayoutWidth - 1) + && width <= (mLastLayoutWidth + 1)) { // If the property of text node no change, and the current layout width is equal // to the last measurement result, no need to create layout again. return mLayout; @@ -468,7 +469,7 @@ protected Layout createLayout(final float width, final FlexMeasureMode widthMode } else { float desiredWidth = Layout.getDesiredWidth(mSpanned, textPaint); if (!unconstrainedWidth && (widthMode == FlexMeasureMode.EXACTLY - || desiredWidth > width)) { + || desiredWidth > width)) { desiredWidth = width; } layout = buildStaticLayout(mSpanned, textPaint, (int) Math.ceil(desiredWidth));