Show Android Toast in Singeton design pattern with queue.
- If multiple same toast are generated simultaneously, all toasts will be merged into one. Currently all the toasts shows one after another, creating bad UX.
- If multiple different toasts are generated, it will be displaced in a queue on after another.
Add to root project gradle
allprojects {
repositories {
maven {
url "https://jitpack.io"
}
}
}
Add dependency to app gradle
implementation 'com.github.collegeduniadevelopers:Toastify:Tag'
Show Toast
ToastGenerate.getInstance(context)
.createToastMessage(ToastModel(type: ToastType,title: String, message: String?, leftImg: Drawable?, length: ToastLength? = ToastLength.SHORT))
- ToastType.SUCCESS
- ToastType.NORMAL
- ToastType.ERROR
- ToastType.WARNING
- ToastLength.SHORT
- ToastLength.LONG
That's pretty much it. Thanks