Skip to content

Commit

Permalink
Merge pull request #130 from hotwired/s-pen
Browse files Browse the repository at this point in the history
Fix crash while using a stylus to navigate within the WebView
  • Loading branch information
jayohms authored Jan 12, 2021
2 parents 3b43afe + 009dd6c commit fe2cbb8
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,22 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
internal class TurboSwipeRefreshLayout @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
SwipeRefreshLayout(context, attrs) {

init {
disableCustomDrawingOrder()
}

override fun canChildScrollUp(): Boolean {
val webView = children.firstOrNull() as? WebView
return webView?.scrollY ?: 0 > 0
}

/**
* Disable custom child drawing order. This fixes a crash while using a
* stylus that dispatches hover events when the WebView is being removed.
* This doesn't have any unintended consequences, since the WebView is the
* only possible child of this view.
*/
private fun disableCustomDrawingOrder() {
isChildrenDrawingOrderEnabled = false
}
}

0 comments on commit fe2cbb8

Please sign in to comment.