This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Это объяви в самом верху активити | |
| long seconds = 5000; // 5 секунд | |
| Handler handler = new Handler(); | |
| //Это в onResume | |
| handler.postDelayed(new Runnable() { | |
| @Override | |
| public void run() { | |
| pb.setVisibility(View.VISIBLE); | |
| handler.postDelayed(this,seconds) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Объект, который содержит информацию об обрабатываемом emoji | |
| */ | |
| data class Emoji(val emoji: String, @DrawableRes val resource: Int) | |
| /** | |
| * Список emoji, которые мы умеем кастомизировать | |
| */ | |
| val EMOJIS: List<Emoji> = listOf( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Composable | |
| fun TextWithCustomEmoji( | |
| text: String, | |
| modifier: Modifier = Modifier, | |
| emojis: List<Emoji> = EMOJIS | |
| ) { | |
| val emojiRanges = emojis.findEmojisInText(text) | |
| val annotatedString = buildAnnotatedString { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Composable | |
| fun TextFieldWithCustomEmoji( | |
| value: String, | |
| onValueChange: (String) -> Unit, | |
| modifier: Modifier = Modifier, | |
| enabled: Boolean = true, | |
| readOnly: Boolean = false, | |
| textStyle: TextStyle = LocalTextStyle.current, | |
| label: @Composable (() -> Unit)? = null, | |
| placeholder: @Composable (() -> Unit)? = null, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Composable | |
| private fun DisplayTextWithEmoji( | |
| value: AnnotatedString, | |
| textStyle: TextStyle, | |
| ) { | |
| val textMeasurer = rememberTextMeasurer() | |
| val density = LocalDensity.current | |
| val emojiRanges = EMOJIS.findEmojisInText(value.text) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val message = TextFieldValue(annotatedString = AnnotatedString("some string with tags")) //<-- Строка с тегами | |
| BasicTextField( | |
| value = message, | |
| onValueChange = { newValue: TextFieldValue -> | |
| newValue.annotatedString // <-- Вот тут вы получите строку без тегов | |
| } | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| internal const val ZERO_WIDTH_SEPARATOR = "\u2063" | |
| internal const val MARKER = 'M' | |
| private const val MARKER_LENGTH = MARKER.toString().length + ZERO_WIDTH_SEPARATOR.length | |
| internal fun TextFieldValue.toTextFieldValueWithEmojiMarkers(emojiRanges: List<EmojiRange>): TextFieldValue { | |
| val annotatedString = buildAnnotatedString { | |
| var lastIndex = 0 | |
| // Сортируем диапазоны по началу |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * An object containing information about the emoji being processed. | |
| */ | |
| data class Emoji(val emoji: String, @DrawableRes val resource: Int) | |
| /** | |
| * A list of emojis we can customize | |
| */ | |
| val EMOJIS: List<Emoji> = listOf( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Composable | |
| fun TextFieldWithCustomEmoji( | |
| value: String, | |
| onValueChange: (String) -> Unit, | |
| modifier: Modifier = Modifier, | |
| enabled: Boolean = true, | |
| readOnly: Boolean = false, | |
| textStyle: TextStyle = LocalTextStyle.current, | |
| label: @Composable (() -> Unit)? = null, | |
| placeholder: @Composable (() -> Unit)? = null, |