TastyToast
TastyToast copied to clipboard
Bug in animation on successive toast calls
Animation of toast gets finished by the time it is displayed in case multiple toast are called successively.
Following gif shows finished animation when second toast is displayed.
Thanks for pointing this out. I got what you are trying to say.
Actually that's the way Toasts work in Android i.e. if you want to show another Toast
just after previous one then you can call .cancel()
method on Toast
first and then show second one.
You can apply same concept on TastyToast
too. When you do TastyToast.makeText()
, this method returns a Toast
object(check this https://github.com/yadav-rahul/TastyToast/blob/lib/tastytoast/src/main/java/com/sdsmdg/tastytoast/TastyToast.java#L145). Then you can call .cancel()
to cancel previous Toast and can show new one.
For example: This will solve your issue
- First create a new object like this
Toast tastyToast = TastyToast.makeText(getApplicationContext(), "Hello World !", TastyToast.LENGTH_LONG, TastyToast.WARNING);
- After it whenever you want to dismiss it call
tastyToast.cancel();
@suyashmahar Try it once and do report if this issue still persists.
Strange the copy of code which I had, makeText()
was declared as static. Anyways I changed that.
I used this:
Toast toast = TastyToast.makeText(getApplicationContext(), "Download Successful !", TastyToast.LENGTH_LONG, TastyToast.SUCCESS);
toast.cancel();
toast = TastyToast.makeText(getApplicationContext(), "Download Successful !", TastyToast.LENGTH_LONG, TastyToast.WARNING);
Issue with animation not being played is still not resolved, now just first toast gets dismissed. Animations on second toast are still not played. I think I noticed another bug regarding animation. Animation doesn't play when previous toast was canceled.
@suyashmahar Seems like a bug to me. Would you like to work upon it?
Should I start developing a Toast Manager class to handle all toasts? So that developer can create a toast and send it to toast manager. After which rest would be handled by the class.
@suyashmahar Yes, It would be good idea. Go ahead and make PR for it.
@suyashmahar Any updates on this?
its not working in android 9, but 8.1 and 7 is ok, i have in my project the gradle 0.1.1 but in android pie not work.
Can u help me ?