简体   繁体   English

等待动画完成,然后执行代码

[英]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. 但是,当要从列表视图(也从sqlite)中删除行时,项目将被删除而没有缩小动画。 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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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