LibreTube/app/src/main/java/com/github/libretube/extensions/ToastFromMainThread.kt
2022-11-20 15:54:55 +01:00

21 lines
456 B
Kotlin

package com.github.libretube.extensions
import android.content.Context
import android.os.Handler
import android.os.Looper
import android.widget.Toast
fun Context.toastFromMainThread(text: String) {
Handler(Looper.getMainLooper()).post {
Toast.makeText(
this,
text,
Toast.LENGTH_SHORT
).show()
}
}
fun Context.toastFromMainThread(stringId: Int) {
toastFromMainThread(getString(stringId))
}