TransitionListener callbacks not called when there is nothing to change

瘦欲@ 提交于 2019-12-10 22:19:03

问题


I'm animating between scenes using the TransitionManager and constraint sets using the following code.

val transition = AutoTransition()
transition.addListener(object : Transition.TransitionListener {
    override fun onTransitionEnd(transition: Transition) {
        // do something
    }
})

val constraintSet = ConstraintSet()
constraintSet.clone(this, R.layout.frame_loading)
TransitionManager.beginDelayedTransition(rootLayout, transition)
constraintSet.applyTo(rootLayout)

There's something I want to do when the transition ends, hence the callback. However there are situations when there are views to change and when there are no views to change. When there is nothing to change there is no transition and the callback is not called (as explained here), which is a problem because the action that's supposed to run on transition end is not run. Is there good way of solving this that's not some hack like moving an invisible view or other ways to force a predraw event (which triggers the transition)? Or is there a way to check if the transition is required or not?

来源:https://stackoverflow.com/questions/49588716/transitionlistener-callbacks-not-called-when-there-is-nothing-to-change

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!