Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public open class NavigationDelegate(

public var currentNavigableSetup: ((NavigableCompat) -> Unit)? = null

private var activeTransition: MagellanTransition? = null
private var templatedViewMap = HashMap<NavigableCompat, View>()

protected var containerView: ScreenContainer? = null
Expand Down Expand Up @@ -75,6 +76,7 @@ public open class NavigationDelegate(
direction: Direction,
backStackOperation: (Deque<NavigationEvent>) -> MagellanTransition
) {
activeTransition?.interrupt()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null out activeTransition after this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

containerView?.setInterceptTouchEvents(true)
navigationPropagator.beforeNavigation()
val oldBackStack = backStack.map { it.navigable }
Expand Down Expand Up @@ -140,6 +142,7 @@ public open class NavigationDelegate(
} else {
NoAnimationTransition()
}
activeTransition = transition
transition.animate(from, to, direction) {
if (context != null && containerView != null) {
containerView!!.removeView(from)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class DefaultTransition : MagellanTransition {
private var animator: Animator? = null

override fun interrupt() {
animator?.end()
animator?.cancel()
}

override fun animate(
Expand All @@ -48,15 +48,15 @@ public class DefaultTransition : MagellanTransition {
): AnimatorSet {
val sign = direction.sign()
val axis: Property<View, Float> = View.TRANSLATION_X
val toTranslation = sign * to.width
val toTranslation = sign * to.width + (from?.translationX ?: 0f)
val set = AnimatorSet()
if (from != null) {
val fromTranslation = sign * -from.width
val fromAnimation = ObjectAnimator.ofFloat(from, axis, 0f, fromTranslation.toFloat())
val fromAnimation = ObjectAnimator.ofFloat(from, axis, from.translationX, fromTranslation.toFloat())
set.play(fromAnimation)
}

val toAnimation = ObjectAnimator.ofFloat(to, axis, toTranslation.toFloat(), 0f)
val toAnimation = ObjectAnimator.ofFloat(to, axis, toTranslation, 0f)
set.play(toAnimation)
set.interpolator = FastOutSlowInInterpolator()
return set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ internal class IntroStep(
) : Step<IntroBinding>(IntroBinding::inflate) {

override fun onShow(context: Context, binding: IntroBinding) {
binding.root.tag = "IntroStep"
binding.learnMore.setOnClickListener {
println("viewBinding: $viewBinding")
viewBinding!!
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would have crashed otherwise?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this bit now, but yes it was for reproducing a sneaky crash caused by triggering a button click during the transition animation. The transition is a critical moment where the outbound step has been moved to a Hidden state, and so the viewBinding property will return null, but the Step's View is still attached to the window and animating out for a short time. Any input event listeners still attached to that View are still active

goToLearnMore()
}
}
Expand Down
1 change: 1 addition & 0 deletions magellan-sample/src/main/res/layout/learn_more.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
android:layout_height="match_parent"
android:background="@color/colorCyan"
android:orientation="vertical"
android:tag="LearnMore"
tools:ignore="Overdraw"
>

Expand Down
Loading