Permalink
Browse files

Clear all parent references when ExpandablePageLayout is detached

  • Loading branch information...
saket committed Oct 14, 2018
1 parent 68a9ede commit 0b80ec6d2da1817959efde8b301a93de5efa8e37
@@ -80,11 +80,11 @@ class InboxRecyclerView(
}

override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
if (pageSetupDone) {
itemExpandAnimator.onDetachRecyclerView(this)
tintPainter.onDetachRecyclerView(this)
}
super.onDetachedFromWindow()
}

/**
@@ -30,7 +30,7 @@ open class ExpandablePageLayout @JvmOverloads constructor(
/** Alpha of this page when it's collapsed. */
internal var collapsedAlpha = 0F

var pullToCollapseInterceptor: OnPullToCollapseInterceptor = { _, _, _ -> InterceptResult.IGNORED }
var pullToCollapseInterceptor: OnPullToCollapseInterceptor = IGNORE_ALL_PULL_TO_COLLAPSE_INTERCEPTOR

/** Minimum Y-distance the page has to be pulled before it's eligible for collapse. */
var pullToCollapseThresholdDistance: Int
@@ -102,6 +102,16 @@ open class ExpandablePageLayout @JvmOverloads constructor(
}.start()
}

override fun onDetachedFromWindow() {
pullToCollapseInterceptor = IGNORE_ALL_PULL_TO_COLLAPSE_INTERCEPTOR
parentToolbar = null
nestedPage = null
internalStateCallbacksForNestedPage = InternalPageCallbacks.NoOp()
internalStateCallbacksForRecyclerView = InternalPageCallbacks.NoOp()
stateChangeCallbacks.clear()
super.onDetachedFromWindow()
}

private fun changeState(newPageState: PageState) {
currentState = newPageState
}
@@ -20,3 +20,5 @@ package me.saket.inboxrecyclerview.page
* @return True to consume this touch event. False otherwise.
*/
typealias OnPullToCollapseInterceptor = (downX: Float, downY: Float, upwardPull: Boolean) -> InterceptResult

val IGNORE_ALL_PULL_TO_COLLAPSE_INTERCEPTOR : OnPullToCollapseInterceptor = { _, _, _ -> InterceptResult.IGNORED }

0 comments on commit 0b80ec6

Please sign in to comment.