Skip to content

Commit

Permalink
Do not detect gestures in top 48dp of screen
Browse files Browse the repository at this point in the history
  • Loading branch information
jorritsmit committed Oct 28, 2020
1 parent a670d2c commit 02c60c7
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class PlayerFragment : Fragment() {
private var isZoomEnabled = false

private val swipeGesturesEnabled by appPreferences::exoPlayerAllowSwipeGestures
private val gestureThresholdDp = 48.0f

/**
* Tracks a value during a swipe gesture (between multiple onScroll calls).
Expand Down Expand Up @@ -280,6 +281,11 @@ class PlayerFragment : Fragment() {
if (!swipeGesturesEnabled)
return false

// Check whether swipe was started in excluded region
val scale: Float = resources.displayMetrics.density
if (firstEvent.y.toInt() < gestureThresholdDp * scale)
return false

// Check whether swipe was oriented vertically
if (abs(distanceY / distanceX) < 2)
return false
Expand Down

0 comments on commit 02c60c7

Please sign in to comment.