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 {