Skip to content
This repository has been archived by the owner on Jul 13, 2020. It is now read-only.

Return toast object in toast helper functions. #511

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions anko/library/static/commons/src/dialogs/Toasts.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

@file:Suppress("NOTHING_TO_INLINE", "unused")

package org.jetbrains.anko

import android.app.Fragment
Expand All @@ -40,7 +41,11 @@ inline fun Fragment.toast(message: Int) = activity.toast(message)
*
* @param message the message text resource.
*/
fun Context.toast(message: Int) = Toast.makeText(this, message, Toast.LENGTH_SHORT).show()
inline fun Context.toast(message: Int): Toast = Toast
.makeText(this, message, Toast.LENGTH_SHORT)
.apply {
show()
}

/**
* Display the simple Toast message with the [Toast.LENGTH_SHORT] duration.
Expand All @@ -61,7 +66,11 @@ inline fun Fragment.toast(message: CharSequence) = activity.toast(message)
*
* @param message the message text.
*/
fun Context.toast(message: CharSequence) = Toast.makeText(this, message, Toast.LENGTH_SHORT).show()
inline fun Context.toast(message: CharSequence): Toast = Toast
.makeText(this, message, Toast.LENGTH_SHORT)
.apply {
show()
}

/**
* Display the simple Toast message with the [Toast.LENGTH_LONG] duration.
Expand All @@ -82,7 +91,11 @@ inline fun Fragment.longToast(message: Int) = activity.longToast(message)
*
* @param message the message text resource.
*/
inline fun Context.longToast(message: Int) = Toast.makeText(this, message, Toast.LENGTH_LONG).show()
inline fun Context.longToast(message: Int): Toast = Toast
.makeText(this, message, Toast.LENGTH_LONG)
.apply {
show()
}

/**
* Display the simple Toast message with the [Toast.LENGTH_LONG] duration.
Expand All @@ -103,4 +116,8 @@ inline fun Fragment.longToast(message: CharSequence) = activity.longToast(messag
*
* @param message the message text.
*/
inline fun Context.longToast(message: CharSequence) = Toast.makeText(this, message, Toast.LENGTH_LONG).show()
inline fun Context.longToast(message: CharSequence): Toast = Toast
.makeText(this, message, Toast.LENGTH_LONG)
.apply {
show()
}