Skip to content

Instantly share code, notes, and snippets.

View elsennov's full-sized avatar

Elsen Novraditya elsennov

  • Jakarta, Indonesia
View GitHub Profile
@elsennov
elsennov / hotline_init
Created July 22, 2017 04:19
Hotline Initialization
fun initHotline(applicationContext: Context) {
initHotlineBaseConfig(applicationContext)
initHotlineNotification(applicationContext)
initHotlineUser(applicationContext)
}
private fun initHotlineBaseConfig(applicationContext: Context) {
val hotlineConfig = HotlineConfig(BuildConfig.HOTLINE_APP_ID, BuildConfig.HOTLINE_APP_KEY)
Hotline.getInstance(applicationContext).init(hotlineConfig)
}
@elsennov
elsennov / coroutine_example
Created July 25, 2017 02:50
Coroutine async UI
private fun applyHashtagSpanForResiNumber(fullText: String,
messageEditorSpannable: Spannable) {
launch(UI) {
var indexAsync = async(CommonPool, CoroutineStart.LAZY) {
fullText.indexOf(RESI_NUMBER, 0)
}
while (indexAsync.await() != -1) {
val hashtagSpanAsync = async(CommonPool, CoroutineStart.LAZY) {
CharacterStyle.wrap(hashtagForegroundColorSpan)
}