Skip to content

Instantly share code, notes, and snippets.

@illuzor illuzor/async.kt Secret
Created Sep 14, 2018

Embed
What would you like to do?
package com.illuzor.lesson.wallpapers.extensions
import android.os.Handler
import android.os.Looper
fun runInBackground(handler: () -> Unit) = Thread(Runnable(handler)).start()
fun runInMainThread(handler: () -> Unit) {
if (Looper.myLooper() == Looper.getMainLooper()) {
handler()
} else {
Handler(Looper.getMainLooper()).post(Runnable(handler))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.