android - AnimationEnd is triggered on all View at once -
i have application 3 image buttons (based on custom image button) image button has animation end listened, once first image button completes animation, instances of custom images buttons trigger animationend method.
here's code:
import java.util.concurrent.callable; import android.content.context; import android.util.attributeset; import android.widget.imagebutton; class myimagebutton extends imagebutton{ protected callable<void> animend = null; public void setonanimationendlistener(callable<void> animend1) { this.animend = animend1; } public myimagebutton(context context) { super(context); // todo auto-generated constructor stub } public myimagebutton(context context, attributeset attrs) { super(context, attrs); // todo auto-generated constructor stub } public myimagebutton(context context, attributeset attrs, int defstyle) { super(context, attrs, defstyle); // todo auto-generated constructor stub } @override protected void onanimationend() { super.onanimationend(); //functionality here if(this.animend != null){ try{ this.animend.call(); } catch(exception e){ } } } }
notice 3 image buttons animate offset 2 seconds (2000 msec) away each other.
i set callback image button follows:
object1.setonanimationendlistener(new callable<void>() { @override public void call() throws exception { object1.setanimation(null); object1.setlayoutparams(params); // todo auto-generated method stub return null; } }); // object2, object3 of them instances of myimagebutton
Comments
Post a Comment