pref: 使 `getEmoticonHeightPx` 稳定
This commit is contained in:
parent
0d1c565fdf
commit
2ef051f7fa
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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<String, String> = mapOf(
|
||||
"呵呵" to "image_emoticon1",
|
||||
|
|
@ -106,17 +117,6 @@ object EmoticonManager {
|
|||
private val drawableCache: MutableMap<String, Drawable> = 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<String, InlineTextContent> {
|
||||
|
|
|
|||
Loading…
Reference in New Issue