Split EmojiDataSource - avoid !!

This commit is contained in:
Benoit Marty 2019-12-09 22:57:23 +01:00
parent 2972177541
commit 80306f20df

View file

@ -19,6 +19,23 @@ package im.vector.riotx.features.reactions.data
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
/**
* name: 'a',
* unified: 'b',
* non_qualified: 'c',
* has_img_apple: 'd',
* has_img_google: 'e',
* has_img_twitter: 'f',
* has_img_emojione: 'g',
* has_img_facebook: 'h',
* has_img_messenger: 'i',
* keywords: 'j',
* sheet: 'k',
* emoticons: 'l',
* text: 'm',
* short_names: 'n',
* added_in: 'o'
*/
@JsonClass(generateAdapter = true)
data class EmojiItem(
@Json(name = "a") val name: String,
@ -26,14 +43,14 @@ data class EmojiItem(
@Json(name = "j") val keywords: List<String>?
) {
var _emojiText: String? = null
private var emojiText: String? = null
fun emojiString(): String {
if (_emojiText == null) {
emojiText?.let { return it }
val utf8Text = unicode.split("-").joinToString("") { "\\u$it" } // "\u0048\u0065\u006C\u006C\u006F World"
_emojiText = fromUnicode(utf8Text)
}
return _emojiText!!
return fromUnicode(utf8Text)
.also { emojiText = it }
}
companion object {
@ -50,18 +67,3 @@ data class EmojiItem(
}
}
// name: 'a',
// unified: 'b',
// non_qualified: 'c',
// has_img_apple: 'd',
// has_img_google: 'e',
// has_img_twitter: 'f',
// has_img_emojione: 'g',
// has_img_facebook: 'h',
// has_img_messenger: 'i',
// keywords: 'j',
// sheet: 'k',
// emoticons: 'l',
// text: 'm',
// short_names: 'n',
// added_in: 'o',