Skip to content

Instantly share code, notes, and snippets.

@natiginfo
Created May 17, 2019 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save natiginfo/2d2ad248aed18a1abb850989f733e580 to your computer and use it in GitHub Desktop.
Save natiginfo/2d2ad248aed18a1abb850989f733e580 to your computer and use it in GitHub Desktop.
Main thread executor
import android.os.Handler
import android.os.Looper
import java.util.concurrent.Executor
class MainThreadExecutor : Executor {
private val mainThreadHandler = Handler(Looper.getMainLooper())
override fun execute(command: Runnable) {
mainThreadHandler.post(command)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment