I have a fragment, here is the onCreateView method:
@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;
}
I need to remove the fragment using getActivity().getSupportFragmentManager().beginTransaction().remove(this).commit();
when the lottie animation has ended. If I understand correctly when the isAnimating()
Lottie method returns false the animation has ended and since in my configuration the animation does not loop this is when I should remove the current fragment. But I can't just use an if statement since when it is executed the animation may still be going.
I need a way to remove the fragment when the Lottie animation ends, how do I do this?