我有一个片段,这里是onCreateView方法:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
mView = inflater.inflate(R.layout.fragment_added_to_cart_anim, container, false);
ButterKnife.bind(this, mView);
mAddedToCartAnimation.setAnimation("checked_done_.json");
mAddedToCartAnimation.loop(false);
mAddedToCartAnimation.playAnimation();
// Remove fragment when the animation is finished.
return mView;
}
当 lottie 动画结束时,我需要使用
getActivity().getSupportFragmentManager().beginTransaction().remove(this).commit();
去除片段。如果我理解正确,当 isAnimating()
Lottie 方法返回 false 时,动画已经结束了,由于在我的配置中动画不会循环,因此这是我应该删除当前片段的时候。但是我不能仅使用 if 语句,因为当它执行时,动画可能仍在进行中。我需要一种方法,在 Lottie 动画结束时移除片段,我该怎么做?