Merge branch 'doubletap_scroll_fix' into 'master'
Try making doubletap less sensible See merge request pixeldroid/PixelDroid!328
This commit is contained in:
commit
4d1efdfea4
@ -51,7 +51,7 @@ class NestedScrollableHost : ConstraintLayout {
|
|||||||
return v as? ViewPager2
|
return v as? ViewPager2
|
||||||
}
|
}
|
||||||
|
|
||||||
var doubleTapCallback: ((Unit) -> Unit)? = null
|
var doubleTapCallback: ((Boolean) -> Unit)? = null
|
||||||
|
|
||||||
private val child: View? get() = if (childCount > 0) getChildAt(0) else null
|
private val child: View? get() = if (childCount > 0) getChildAt(0) else null
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ class NestedScrollableHost : ConstraintLayout {
|
|||||||
if (e.action == MotionEvent.ACTION_DOWN) {
|
if (e.action == MotionEvent.ACTION_DOWN) {
|
||||||
initialX = e.x
|
initialX = e.x
|
||||||
initialY = e.y
|
initialY = e.y
|
||||||
doubleTapCallback?.invoke(Unit)
|
doubleTapCallback?.invoke(true)
|
||||||
}
|
}
|
||||||
// Early return if child can't scroll in same direction as parent
|
// Early return if child can't scroll in same direction as parent
|
||||||
if (!canChildScroll(orientation, -1f) && !canChildScroll(orientation, 1f)) {
|
if (!canChildScroll(orientation, -1f) && !canChildScroll(orientation, 1f)) {
|
||||||
@ -98,6 +98,8 @@ class NestedScrollableHost : ConstraintLayout {
|
|||||||
val scaledDy = dy.absoluteValue * if (isVpHorizontal) 1f else .5f
|
val scaledDy = dy.absoluteValue * if (isVpHorizontal) 1f else .5f
|
||||||
|
|
||||||
if (scaledDx > touchSlop || scaledDy > touchSlop) {
|
if (scaledDx > touchSlop || scaledDy > touchSlop) {
|
||||||
|
doubleTapCallback?.invoke(false)
|
||||||
|
|
||||||
if (isVpHorizontal == (scaledDy > scaledDx)) {
|
if (isVpHorizontal == (scaledDy > scaledDx)) {
|
||||||
// Gesture is perpendicular, allow all parents to intercept
|
// Gesture is perpendicular, allow all parents to intercept
|
||||||
parent.requestDisallowInterceptTouchEvent(false)
|
parent.requestDisallowInterceptTouchEvent(false)
|
||||||
|
@ -457,7 +457,8 @@ class StatusViewHolder(val binding: PostFragmentBinding) : RecyclerView.ViewHold
|
|||||||
//Activate double tap liking
|
//Activate double tap liking
|
||||||
var clicked = false
|
var clicked = false
|
||||||
binding.postPagerHost.doubleTapCallback = {
|
binding.postPagerHost.doubleTapCallback = {
|
||||||
lifecycleScope.launchWhenCreated {
|
if(!it) clicked = false
|
||||||
|
else lifecycleScope.launchWhenCreated {
|
||||||
//Check that the post isn't hidden
|
//Check that the post isn't hidden
|
||||||
if(binding.sensitiveWarning.visibility == View.GONE) {
|
if(binding.sensitiveWarning.visibility == View.GONE) {
|
||||||
//Check for double click
|
//Check for double click
|
||||||
@ -480,7 +481,6 @@ class StatusViewHolder(val binding: PostFragmentBinding) : RecyclerView.ViewHold
|
|||||||
binding.postPager.handler.postDelayed(fun() { clicked = false }, 500)
|
binding.postPager.handler.postDelayed(fun() { clicked = false }, 500)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user