ProductPromotion
Logo

Kotlin

made by https://0x3d.site

GitHub - 5AbhishekSaxena/toaster-android: A simple library to add custom toast to android applications.
A simple library to add custom toast to android applications. - 5AbhishekSaxena/toaster-android
Visit Site

GitHub - 5AbhishekSaxena/toaster-android: A simple library to add custom toast to android applications.

GitHub - 5AbhishekSaxena/toaster-android: A simple library to add custom toast to android applications.

Toaster-Android

GitHub release (latest by date including pre-releases) GitHub GitHub (Pre-)Release Date Language

Toaster-Android is a simple open source library to customize toast messages in android applications. It has some predefined templates for common use-cases like warning, error and success messages.

Download

Step 1

Add the JitPack repository to your build.gradle(project).

allprojects {
  repositories {
  	...
  	maven { url 'https://jitpack.io' }
  }
}

Step 2

Add the dependency to your build.gradle(Module: app).

dependencies {
  implementation 'com.github.5AbhishekSaxena.toaster-android:toaster:2.3.1'
  implementation 'com.github.5AbhishekSaxena.toaster-android:toaster-ktx:2.3.1' //for ktx support
}

Please Note: toaster-ktx includes toaster module so, if you are using toaster-ktx version then you don't have to add taoster

How to use Toaster-Android

Video:

A simple use case will look like this

Toaster.pop(
             this,
             "A simple toast message"
         ).show()

With a custom drawable

Toaster.pop(
              this,
              "A simple toast message with image",
              R.drawable.ic_baseline_cloud_done_24 /* image */
          ).show()

Code Snippets

Using templates
  • Success
	Toaster.popSuccess(
                  this,
                  "This is a success message",
                  Toaster.LENGTH_SHORT
              ).show()
  • Warning
	Toaster.popWarning(
              this,
              "This is a warning message",
              Toaster.LENGTH_SHORT
          ).show()
  • Error
	Toaster.popError(
              this,
              "This is an error message",
              Toaster.LENGTH_SHORT
          ).show()
Custom Toast
  1. Create a toast config
      val toastConfig = Toaster.Config(
              message = "File uploaded successfully",
              leftDrawableRes = R.drawable.ic_baseline_cloud_done_24,
              leftDrawableTint = R.color.blue,
              stripTint = R.color.blue,
              duration = Toaster.LENGTH_SHORT,
          )
  1. Add the config to the Toaster.pop
    Toaster.pop(toastConfig.make(context)).show()
Custom Toast (toaster-ktx)

With the toaster-ktx, you can either make Taoster or directly create Toast with the provided functions.

  1. Create Taoster and then poping it.
  • Create Taoster usign ktx
val toaster = prepareToaster(this) {
             message = "File uploaded successfully"
             leftDrawableRes = R.drawable.ic_baseline_cloud_done_24
             leftDrawableTint = R.color.blue
             stripTint = R.color.blue
             duration = Toaster.LENGTH_SHORT
         }
Toaster.pop(toaster).show()
  • Pop the Toast
Toaster.pop(toaster).show()
  1. Directly make Toast and show it
prepareToast(this) {
             message = "File uploaded successfully"
             leftDrawableRes = R.drawable.ic_baseline_cloud_done_24
             leftDrawableTint = R.color.blue
             stripTint = R.color.blue
             duration = Toaster.LENGTH_SHORT
 }.show()

Contributing

  • For contributions in this repository, please read Contribution guidelines for this project first. (Please pull the changes from this repo if you have already forked the repository and are facing conflicts)
  • If you like the repository, please star it.

License

MIT License. See the LICENSE file for details

Author

Abhishek Saxena

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory