yadav-rahul / TastyToast

:bread: Make your native android Toasts Tasty
2.04k stars 355 forks source link

Bug in animation on successive toast calls #21

Open suyashmahar opened 7 years ago

suyashmahar commented 7 years ago

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

yadav-rahul commented 7 years ago

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

@suyashmahar Try it once and do report if this issue still persists.

suyashmahar commented 7 years ago

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.

yadav-rahul commented 7 years ago

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

suyashmahar commented 7 years ago

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.

yadav-rahul commented 7 years ago

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

yadav-rahul commented 7 years ago

@suyashmahar Any updates on this?

lucazin commented 5 years ago

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 ?