Last active
September 29, 2019 09:14
-
-
Save robertlevonyan/56ff29edb6d5c6d2da7fb051d2eee771 to your computer and use it in GitHub Desktop.
This file contains 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
fun setTextAsync(textView: TextView, longString: String) { | |
val params = textView.textMetricsParams | |
val ref = WeakReference(textView) | |
CoroutineScope.launch(Dispatchers.Default) { | |
val pText = PrecomputedText.create(longString, params) | |
withContext(Dispatchers.Main) { | |
ref.get()?.let { textView -> | |
textView.text = pText | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment