Skip to content

Instantly share code, notes, and snippets.


illuzor/toast.kt Secret

Created Sep 14, 2018
What would you like to do?
package com.illuzor.lesson.wallpapers.extensions
import android.content.Context
import android.widget.Toast
import androidx.annotation.StringRes
inline fun Context.toast(@StringRes id: Int, showLong: Boolean = false): Toast =
Toast.makeText(this, id, if (showLong) Toast.LENGTH_LONG else Toast.LENGTH_SHORT).apply { show() }
inline fun Fragment.toast(@StringRes resID: Int, showLong: Boolean = false): Toast = activity!!.toast(resID, showLong)
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.