diff --git a/app/src/main/java/com/h/pixeldroid/posts/NestedScrollableHost.kt b/app/src/main/java/com/h/pixeldroid/posts/NestedScrollableHost.kt index 49b3ac60..5eeaecc2 100644 --- a/app/src/main/java/com/h/pixeldroid/posts/NestedScrollableHost.kt +++ b/app/src/main/java/com/h/pixeldroid/posts/NestedScrollableHost.kt @@ -51,7 +51,7 @@ class NestedScrollableHost : ConstraintLayout { 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 @@ -79,7 +79,7 @@ class NestedScrollableHost : ConstraintLayout { if (e.action == MotionEvent.ACTION_DOWN) { initialX = e.x initialY = e.y - doubleTapCallback?.invoke(Unit) + doubleTapCallback?.invoke(true) } // Early return if child can't scroll in same direction as parent if (!canChildScroll(orientation, -1f) && !canChildScroll(orientation, 1f)) { @@ -98,6 +98,8 @@ class NestedScrollableHost : ConstraintLayout { val scaledDy = dy.absoluteValue * if (isVpHorizontal) 1f else .5f if (scaledDx > touchSlop || scaledDy > touchSlop) { + doubleTapCallback?.invoke(false) + if (isVpHorizontal == (scaledDy > scaledDx)) { // Gesture is perpendicular, allow all parents to intercept parent.requestDisallowInterceptTouchEvent(false) diff --git a/app/src/main/java/com/h/pixeldroid/posts/StatusViewHolder.kt b/app/src/main/java/com/h/pixeldroid/posts/StatusViewHolder.kt index 4d8e4566..1fbb6033 100644 --- a/app/src/main/java/com/h/pixeldroid/posts/StatusViewHolder.kt +++ b/app/src/main/java/com/h/pixeldroid/posts/StatusViewHolder.kt @@ -457,7 +457,8 @@ class StatusViewHolder(val binding: PostFragmentBinding) : RecyclerView.ViewHold //Activate double tap liking var clicked = false binding.postPagerHost.doubleTapCallback = { - lifecycleScope.launchWhenCreated { + if(!it) clicked = false + else lifecycleScope.launchWhenCreated { //Check that the post isn't hidden if(binding.sensitiveWarning.visibility == View.GONE) { //Check for double click @@ -480,7 +481,6 @@ class StatusViewHolder(val binding: PostFragmentBinding) : RecyclerView.ViewHold binding.postPager.handler.postDelayed(fun() { clicked = false }, 500) } } - } } }