From 2ef051f7fab0165a2f93c135acd69d994e8a53f7 Mon Sep 17 00:00:00 2001 From: HuanCheng65 <22636177+HuanCheng65@users.noreply.github.com> Date: Tue, 11 Jul 2023 14:48:33 +0800 Subject: [PATCH] =?UTF-8?q?pref:=20=E4=BD=BF=20`getEmoticonHeightPx`=20?= =?UTF-8?q?=E7=A8=B3=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tieba/post/ui/widgets/compose/Texts.kt | 2 +- .../tieba/post/utils/EmoticonManager.kt | 22 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/huanchengfly/tieba/post/ui/widgets/compose/Texts.kt b/app/src/main/java/com/huanchengfly/tieba/post/ui/widgets/compose/Texts.kt index 406daf8e..f79d88ad 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/ui/widgets/compose/Texts.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/ui/widgets/compose/Texts.kt @@ -35,8 +35,8 @@ import com.huanchengfly.tieba.post.pxToDp import com.huanchengfly.tieba.post.pxToSp import com.huanchengfly.tieba.post.ui.common.theme.compose.ExtendedTheme import com.huanchengfly.tieba.post.utils.EmoticonManager -import com.huanchengfly.tieba.post.utils.EmoticonManager.getEmoticonHeightPx import com.huanchengfly.tieba.post.utils.EmoticonUtil.emoticonString +import com.huanchengfly.tieba.post.utils.getEmoticonHeightPx @Composable diff --git a/app/src/main/java/com/huanchengfly/tieba/post/utils/EmoticonManager.kt b/app/src/main/java/com/huanchengfly/tieba/post/utils/EmoticonManager.kt index 7c8f641e..99569a08 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/utils/EmoticonManager.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/utils/EmoticonManager.kt @@ -37,6 +37,17 @@ import kotlinx.coroutines.launch import java.io.File import java.lang.ref.WeakReference +@OptIn(ExperimentalTextApi::class) +@Composable +fun getEmoticonHeightPx(style: TextStyle): Int { + val textMeasurer = rememberTextMeasurer() + val textLayoutResult = textMeasurer.measure( + AnnotatedString(stringResource(id = R.string.emoticon_default)), + style + ) + return textLayoutResult.size.height +} + object EmoticonManager { private val DEFAULT_EMOTICON_MAPPING: Map = mapOf( "呵呵" to "image_emoticon1", @@ -106,17 +117,6 @@ object EmoticonManager { private val drawableCache: MutableMap = mutableMapOf() private val coroutineScope: CoroutineScope = CoroutineScope(Dispatchers.IO) - @OptIn(ExperimentalTextApi::class) - @Composable - fun getEmoticonHeightPx(style: TextStyle): Int { - val textMeasurer = rememberTextMeasurer() - val textLayoutResult = textMeasurer.measure( - AnnotatedString(stringResource(id = R.string.emoticon_default)), - style - ) - return textLayoutResult.size.height - } - fun getEmoticonInlineContent( sizePx: Int ): Map {