From 2e6652f5acf228e283615bc3e29a2e8563d0b3e7 Mon Sep 17 00:00:00 2001 From: Cintory Date: Thu, 13 Jun 2024 18:35:16 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E4=B8=8D=E8=A7=A3=E6=9E=90=E5=A4=8D=E6=9D=82=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../s1next/data/api/model/search/ForumSearchResult.kt | 8 ++++++++ app/src/main/res/layout/item_search_forum.xml | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/me/ykrank/s1next/data/api/model/search/ForumSearchResult.kt b/app/src/main/java/me/ykrank/s1next/data/api/model/search/ForumSearchResult.kt index b47d769ef..4d7fcaa41 100644 --- a/app/src/main/java/me/ykrank/s1next/data/api/model/search/ForumSearchResult.kt +++ b/app/src/main/java/me/ykrank/s1next/data/api/model/search/ForumSearchResult.kt @@ -1,6 +1,8 @@ package me.ykrank.s1next.data.api.model.search +import android.text.Spanned import com.github.ykrank.androidtools.ui.adapter.StableIdModel +import me.ykrank.s1next.widget.span.HtmlCompat /** * Created by ykrank on 2016/10/18. @@ -9,6 +11,12 @@ import com.github.ykrank.androidtools.ui.adapter.StableIdModel class ForumSearchResult : StableIdModel, SearchResult() { var content: String? = null + private var _htmlContent: Spanned? = null + val htmlContent: Spanned? + get() = if (_htmlContent != null || content == null) + _htmlContent + else + HtmlCompat.fromHtml(content, HtmlCompat.FROM_HTML_MODE_COMPACT_EXCLUDE_BLOCKQUOTE) override fun equals(o: Any?): Boolean { if (this === o) return true diff --git a/app/src/main/res/layout/item_search_forum.xml b/app/src/main/res/layout/item_search_forum.xml index b836a7253..346f764d3 100644 --- a/app/src/main/res/layout/item_search_forum.xml +++ b/app/src/main/res/layout/item_search_forum.xml @@ -31,7 +31,7 @@ android:lineSpacingExtra="@dimen/text_line_spacing_extra" android:textAppearance="@style/TextAppearance.AppCompat.Body1" android:textIsSelectable="true" - app:imgHtml="@{model.content}" + android:text="@{model.htmlContent}" app:movementMethod="@{SearchMovementMethod.instance}" tools:text="ABC\nkhk"/> From d5ee1e8b03d598b80fee0f05790f38eac7919529 Mon Sep 17 00:00:00 2001 From: Cintory Date: Thu, 13 Jun 2024 22:20:34 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=5FhtmlContent=E6=9C=AA?= =?UTF-8?q?=E8=B5=8B=E5=80=BC=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/api/model/search/ForumSearchResult.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/me/ykrank/s1next/data/api/model/search/ForumSearchResult.kt b/app/src/main/java/me/ykrank/s1next/data/api/model/search/ForumSearchResult.kt index 4d7fcaa41..f6e014f97 100644 --- a/app/src/main/java/me/ykrank/s1next/data/api/model/search/ForumSearchResult.kt +++ b/app/src/main/java/me/ykrank/s1next/data/api/model/search/ForumSearchResult.kt @@ -13,10 +13,14 @@ class ForumSearchResult : StableIdModel, SearchResult() { var content: String? = null private var _htmlContent: Spanned? = null val htmlContent: Spanned? - get() = if (_htmlContent != null || content == null) - _htmlContent - else - HtmlCompat.fromHtml(content, HtmlCompat.FROM_HTML_MODE_COMPACT_EXCLUDE_BLOCKQUOTE) + get() { + if (_htmlContent == null && content != null) + _htmlContent = HtmlCompat.fromHtml( + content, + HtmlCompat.FROM_HTML_MODE_COMPACT_EXCLUDE_BLOCKQUOTE + ) + return _htmlContent + } override fun equals(o: Any?): Boolean { if (this === o) return true