Android - wait for animation to finish before continuing? -


i've spend quite while trying find out how wait animation finish before continuing code. far i've tried while(animation.hasended() == false), using thread.sleep, using timer can't seem work.

something cropped quite few times add animation listener animation, i've tried not sure how progress further.

i create animation, start animation , have line of code after, want executed after animation has finished:

    animation movedown = allanimstuff(duration); //creates animation       image.startanimation(movedown); // start animation     displayscore(score); // wait animation finish before executing line 

and here allanimstuff(duration) method used create animation:

private animation allanimstuff(final long duration) {          animation movedown = new translateanimation(image.getx(), image.getx(), (-image.getheight()), pxheight - image.getheight() / 2); //creates animation         movedown.setduration(duration);         movedown.setfillafter(false);          movedown.setanimationlistener(new animation.animationlistener() {             @override             public void onanimationstart(animation animation) {                  //some code make wait here?              }              @override             public void onanimationend(animation animation) {                 image.sety((pxheight / 2 - image.getheight()));              }              @override             public void onanimationrepeat(animation animation) {             }         });           return movedown;     } 

write following line in onanimationend method

 displayscore(score); 

for example

private animation allanimstuff(final long duration) {          animation movedown = new translateanimation(image.getx(), image.getx(), (-image.getheight()), pxheight - image.getheight() / 2); //creates animation         movedown.setduration(duration);         movedown.setfillafter(false);          movedown.setanimationlistener(new animation.animationlistener() {             @override             public void onanimationstart(animation animation) {                  //some code make wait here?              }              @override             public void onanimationend(animation animation) {                 image.sety((pxheight / 2 - image.getheight()));              displayscore(score);             }              @override             public void onanimationrepeat(animation animation) {             }         });           return movedown;     } 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -