简体   繁体   中英

wait for animation to complete and then execute the code

I am using a custom animation library.

The zoomin animation works well

YoYo.with(Techniques.ZoomIn).duration(700).playOn(retView);

But then, when it comes to deleting the row from the listview (also from the sqlite), the items gets deleted without zoomout animation. When I remove the code for deletion, I can see the zoomout animation.

public void onClick(View v) {
      Log.d("HirakDebug", "tCA delete button pressed");
      String row = row_id;
      YoYo.with(Techniques.ZoomOut).duration(700).playOn(retView);
      taskslist.closeAnimate(pos);
      tasksDatabaseOperations.deleteItemWithTask(row_id);
      adapter.notifyDataSetChanged();
      cursor.requery();
   }

How can I do such that first animation is completed and then the deletion occurs?

You could try the follow, calling the delete methods after the animation has ended.

     YoYo.with(Techniques.ZoomOut)
    .withListener(new Animator.AnimatorListener() {
     @Override
       public void onAnimationStart(Animator animation) {

       }
       @Override
       public void onAnimationEnd(Animator animation) {
         tasksDatabaseOperations.deleteItemWithTask(row_id);
         adapter.notifyDataSetChanged();
         cursor.requery();
       }
       @Override
       public void onAnimationCancel(Animator animation) {

       }
       @Override
       public void onAnimationRepeat(Animator animation) {

       }
       })
    .duration(700)
    .playOn(retView);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM