Bug 885717 - Use a property animator for button toast. r=lucasr

This commit is contained in:
Wes Johnston
2013-08-23 17:06:59 -07:00
parent 3b8626d0a0
commit 5a75c01dc1

View File

@@ -31,6 +31,7 @@ import android.widget.TextView;
import java.util.LinkedList;
import org.mozilla.gecko.animation.PropertyAnimator;
import org.mozilla.gecko.R;
import org.mozilla.gecko.gfx.BitmapUtils;
@@ -123,11 +124,9 @@ public class ButtonToast {
mView.setVisibility(View.VISIBLE);
int duration = immediate ? 0 : mView.getResources().getInteger(android.R.integer.config_longAnimTime);
mView.clearAnimation();
AlphaAnimation alpha = new AlphaAnimation(0.0f, 1.0f);
alpha.setDuration(duration);
alpha.setFillAfter(true);
mView.startAnimation(alpha);
PropertyAnimator animator = new PropertyAnimator(duration);
animator.attach(mView, PropertyAnimator.Property.ALPHA, 1.0f);
animator.start();
}
public void hide(boolean immediate, ReasonHidden reason) {
@@ -149,20 +148,20 @@ public class ButtonToast {
mView.setVisibility(View.GONE);
showNextInQueue();
} else {
AlphaAnimation alpha = new AlphaAnimation(1.0f, 0.0f);
alpha.setDuration(duration);
alpha.setFillAfter(true);
alpha.setAnimationListener(new Animation.AnimationListener () {
// Using Android's animation frameworks will not correctly turn off clicking.
// See bug 885717.
PropertyAnimator animator = new PropertyAnimator(duration);
animator.attach(mView, PropertyAnimator.Property.ALPHA, 0.0f);
animator.addPropertyAnimationListener(new PropertyAnimator.PropertyAnimationListener () {
// If we are showing a toast and go in the background
// onAnimationEnd will be called when the app is restored
public void onAnimationEnd(Animation animation) {
public void onPropertyAnimationEnd() {
mView.setVisibility(View.GONE);
showNextInQueue();
}
public void onAnimationRepeat(Animation animation) { }
public void onAnimationStart(Animation animation) { }
public void onPropertyAnimationStart() { }
});
mView.startAnimation(alpha);
animator.start();
}
}