TastyToast icon indicating copy to clipboard operation
TastyToast copied to clipboard

Bug in animation on successive toast calls

Open suyashmahar opened this issue 8 years ago • 7 comments

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. Bug Details

suyashmahar avatar Jan 21 '17 05:01 suyashmahar

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.

yadav-rahul avatar Jan 21 '17 06:01 yadav-rahul

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 avatar Jan 21 '17 07:01 suyashmahar

@suyashmahar Seems like a bug to me. Would you like to work upon it?

yadav-rahul avatar Jan 23 '17 12:01 yadav-rahul

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 avatar Feb 12 '17 07:02 suyashmahar

@suyashmahar Yes, It would be good idea. Go ahead and make PR for it.

yadav-rahul avatar Feb 12 '17 16:02 yadav-rahul

@suyashmahar Any updates on this?

yadav-rahul avatar Feb 24 '17 11:02 yadav-rahul

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 ?

lucazin avatar Jun 10 '19 21:06 lucazin