Skip to content

Commit

Permalink
Add toast extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
muddassir235 committed Sep 2, 2020
1 parent 507d0e3 commit f8b8f47
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions kmacros/src/main/java/com/muddassir/kmacros/context.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,27 @@ import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
import android.os.Bundle
import android.widget.Toast
import kotlin.reflect.KClass

/**
* toast - Show a short toast with the specified text.
*
* @param text The text to show
*/
fun Context.toast(text: String) {
Toast.makeText(this, text, Toast.LENGTH_SHORT).show()
}

/**
* toast - Show a long toast with the specified text.
*
* @param text The text to show
*/
fun Context.toastLong(text: String) {
Toast.makeText(this, text, Toast.LENGTH_LONG).show()
}

/**
* createIntent - Creates an intent for the specified activity <T>.
*
Expand Down
2 changes: 1 addition & 1 deletion kmacros/src/main/java/com/muddassir/kmacros/functions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.muddassir.kmacros
import android.os.Handler

/**
* safe - The action to perform.
* safe - Run a block of code safely. Avoiding any exceptions.
*
* @param action The action to perform safely.
*/
Expand Down

0 comments on commit f8b8f47

Please sign in to comment.