From 851172a785464df2e52418e4339958cbf574ad22 Mon Sep 17 00:00:00 2001 From: Dimitry Ivanov Date: Tue, 28 Apr 2020 19:19:38 +0300 Subject: [PATCH] Fix table row span width calculation --- build.gradle | 2 +- .../main/java/io/noties/markwon/ext/tables/TableRowSpan.java | 5 +++-- sample/src/main/res/layout/activity_text_view.xml | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 64061d83..89b122ad 100644 --- a/build.gradle +++ b/build.gradle @@ -72,7 +72,7 @@ ext { 'commonmark-table' : "com.atlassian.commonmark:commonmark-ext-gfm-tables:$commonMarkVersion", 'android-svg' : 'com.caverock:androidsvg:1.4', 'android-gif' : 'pl.droidsonroids.gif:android-gif-drawable:1.2.15', - 'jlatexmath-android' : 'ru.noties:jlatexmath-android:0.1.2', + 'jlatexmath-android' : 'ru.noties:jlatexmath-android:0.2.0-SNAPSHOT', 'okhttp' : 'com.squareup.okhttp3:okhttp:3.9.0', 'prism4j' : 'io.noties:prism4j:2.0.0', 'debug' : 'io.noties:debug:5.0.0@jar', diff --git a/markwon-ext-tables/src/main/java/io/noties/markwon/ext/tables/TableRowSpan.java b/markwon-ext-tables/src/main/java/io/noties/markwon/ext/tables/TableRowSpan.java index d00c1850..0bf48626 100644 --- a/markwon-ext-tables/src/main/java/io/noties/markwon/ext/tables/TableRowSpan.java +++ b/markwon-ext-tables/src/main/java/io/noties/markwon/ext/tables/TableRowSpan.java @@ -151,8 +151,9 @@ public class TableRowSpan extends ReplacementSpan { int bottom, @NonNull Paint p) { - if (recreateLayouts(SpanUtils.width(canvas, text))) { - width = canvas.getWidth(); + final int spanWidth = SpanUtils.width(canvas, text); + if (recreateLayouts(spanWidth)) { + width = spanWidth; // @since 4.3.1 it's important to cast to TextPaint in order to display links, etc if (p instanceof TextPaint) { // there must be a reason why this method receives Paint instead of TextPaint... diff --git a/sample/src/main/res/layout/activity_text_view.xml b/sample/src/main/res/layout/activity_text_view.xml index e557a4bc..dcbe4d67 100644 --- a/sample/src/main/res/layout/activity_text_view.xml +++ b/sample/src/main/res/layout/activity_text_view.xml @@ -14,6 +14,7 @@ android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="#000" android:textSize="16sp" + android:padding="8dip" tools:text="whatever" /> \ No newline at end of file