ANDROID_LIVE Telegram 912
​​Абстракция для Strings
#android

Попался любопытный пример работы со строками в Android.
Дело в том, что при использовании строк в больших проектах может возникнуть архитектурная проблема с доступом к Context и получению строк с его использованием.

Автор предлагает использовать sealed-класс для обработки подобных кейсов.

sealed class TextResource {
companion object {
fun fromText(text : String) : TextResource = SimpleTextResource(text)

fun fromStringId(@StringRes id : Int) : TextResource = IdTextResource(id)

fun fromPlural(@PluralRes id: Int, pluralValue : Int) : TextResource = PluralTextResource(id, pluralValue)
}
}


Его просто применять на любых уровнях абстракции. Подробнее в этой статье.
👍9👎3💩3



tgoop.com/android_live/912
Create:
Last Update:

​​Абстракция для Strings
#android

Попался любопытный пример работы со строками в Android.
Дело в том, что при использовании строк в больших проектах может возникнуть архитектурная проблема с доступом к Context и получению строк с его использованием.

Автор предлагает использовать sealed-класс для обработки подобных кейсов.

sealed class TextResource {
companion object {
fun fromText(text : String) : TextResource = SimpleTextResource(text)

fun fromStringId(@StringRes id : Int) : TextResource = IdTextResource(id)

fun fromPlural(@PluralRes id: Int, pluralValue : Int) : TextResource = PluralTextResource(id, pluralValue)
}
}


Его просто применять на любых уровнях абстракции. Подробнее в этой статье.

BY Android Live 🤖




Share with your friend now:
tgoop.com/android_live/912

View MORE
Open in Telegram


Telegram News

Date: |

A few years ago, you had to use a special bot to run a poll on Telegram. Now you can easily do that yourself in two clicks. Hit the Menu icon and select “Create Poll.” Write your question and add up to 10 options. Running polls is a powerful strategy for getting feedback from your audience. If you’re considering the possibility of modifying your channel in any way, be sure to ask your subscribers’ opinions first. Each account can create up to 10 public channels Your posting frequency depends on the topic of your channel. If you have a news channel, it’s OK to publish new content every day (or even every hour). For other industries, stick with 2-3 large posts a week. For crypto enthusiasts, there was the “gm” app, a self-described “meme app” which only allowed users to greet each other with “gm,” or “good morning,” a common acronym thrown around on Crypto Twitter and Discord. But the gm app was shut down back in September after a hacker reportedly gained access to user data. Matt Hussey, editorial director at NEAR Protocol also responded to this news with “#meIRL”. Just as you search “Bear Market Screaming” in Telegram, you will see a Pepe frog yelling as the group’s featured image.
from us


Telegram Android Live 🤖
FROM American