Skip to content

Instantly share code, notes, and snippets.

@illuzor

illuzor/toast.kt Secret

Created September 14, 2018 20:40
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save illuzor/82c63bd6a9e1cbd4b9193f5246dddf73 to your computer and use it in GitHub Desktop.
@file:Suppress("NOTHING_TO_INLINE")
package com.illuzor.lesson.wallpapers.extensions
import android.content.Context
import android.widget.Toast
import androidx.annotation.StringRes
import androidx.fragment.app.Fragment
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