I am working with Shared Element Transitions
between activities. The transition is working fine but I want to know when the shared element transition ends so th
I was struggling to do this in Kotlin using the navigation component but managed to get it working with this
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
setAndPostponeEnterAnimation()
_binding = PokemonDetailFragmentBinding.inflate(inflater, container, false)
setInsets()
handleNavigationArgs()
return binding.root
}
private fun setAndPostponeEnterAnimation() {
postponeEnterTransition()
sharedElementEnterTransition = TransitionInflater.from(context)
.inflateTransition(R.transition.shared_element_transition)
addSharedElementListener()
}
private fun addSharedElementListener() {
(sharedElementEnterTransition as TransitionSet).addListener((object :
TransitionListenerAdapter() {
override fun onTransitionEnd(transition: Transition) {
super.onTransitionEnd(transition)
createRevealAnimation()
}
}))
}
so I can wait for the shared transition to finish before starting a new animation