Fix double tap like
This commit is contained in:
parent
bfb5d93f01
commit
191aa3ff57
|
@ -31,7 +31,7 @@ debugTests:
|
||||||
interruptible: true
|
interruptible: true
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- ./gradlew -Pci --console=plain :app:testDebug
|
- ./gradlew -Pci --console=plain :app:testDebug -x lint
|
||||||
|
|
||||||
|
|
||||||
emulatorTest:
|
emulatorTest:
|
||||||
|
@ -41,13 +41,13 @@ emulatorTest:
|
||||||
- echo no | avdmanager create avd --force --name "api-${API_LEVEL}" --abi "${TARGET}/${ARCH}" --package "system-images;android-${API_LEVEL};${TARGET};${ARCH}"
|
- echo no | avdmanager create avd --force --name "api-${API_LEVEL}" --abi "${TARGET}/${ARCH}" --package "system-images;android-${API_LEVEL};${TARGET};${ARCH}"
|
||||||
- $ANDROID_SDK_ROOT/emulator/emulator -avd "api-${API_LEVEL}" -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -camera-back none &
|
- $ANDROID_SDK_ROOT/emulator/emulator -avd "api-${API_LEVEL}" -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -camera-back none &
|
||||||
- chmod +x android-wait-for-emulator.sh
|
- chmod +x android-wait-for-emulator.sh
|
||||||
- ./gradlew build
|
- ./gradlew build -x lint
|
||||||
- ./android-wait-for-emulator.sh
|
- ./android-wait-for-emulator.sh
|
||||||
- adb shell settings put global window_animation_scale 0.0
|
- adb shell settings put global window_animation_scale 0.0
|
||||||
- adb shell settings put global transition_animation_scale 0.0
|
- adb shell settings put global transition_animation_scale 0.0
|
||||||
- adb shell settings put global animator_duration_scale 0.0
|
- adb shell settings put global animator_duration_scale 0.0
|
||||||
|
|
||||||
- ./gradlew build connectedCheck connectedStagingAndroidTest jacocoTestReport
|
- ./gradlew build connectedCheck connectedStagingAndroidTest jacocoTestReport -x lint
|
||||||
|
|
||||||
- cat app/build/reports/jacoco/jacocoTestReport/html/index.html | grep -o 'Total[^%]*%'
|
- cat app/build/reports/jacoco/jacocoTestReport/html/index.html | grep -o 'Total[^%]*%'
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ import android.util.AttributeSet
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewConfiguration
|
import android.view.ViewConfiguration
|
||||||
import android.widget.FrameLayout
|
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
import androidx.viewpager2.widget.ViewPager2
|
import androidx.viewpager2.widget.ViewPager2
|
||||||
import androidx.viewpager2.widget.ViewPager2.ORIENTATION_HORIZONTAL
|
import androidx.viewpager2.widget.ViewPager2.ORIENTATION_HORIZONTAL
|
||||||
|
@ -52,6 +51,8 @@ class NestedScrollableHost : ConstraintLayout {
|
||||||
return v as? ViewPager2
|
return v as? ViewPager2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var doubleTapCallback: ((Unit) -> 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
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
@ -75,14 +76,17 @@ class NestedScrollableHost : ConstraintLayout {
|
||||||
private fun handleInterceptTouchEvent(e: MotionEvent) {
|
private fun handleInterceptTouchEvent(e: MotionEvent) {
|
||||||
val orientation = parentViewPager?.orientation ?: return
|
val orientation = parentViewPager?.orientation ?: return
|
||||||
|
|
||||||
|
if (e.action == MotionEvent.ACTION_DOWN) {
|
||||||
|
initialX = e.x
|
||||||
|
initialY = e.y
|
||||||
|
doubleTapCallback?.invoke(Unit)
|
||||||
|
}
|
||||||
// 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)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.action == MotionEvent.ACTION_DOWN) {
|
if (e.action == MotionEvent.ACTION_DOWN) {
|
||||||
initialX = e.x
|
|
||||||
initialY = e.y
|
|
||||||
parent.requestDisallowInterceptTouchEvent(true)
|
parent.requestDisallowInterceptTouchEvent(true)
|
||||||
} else if (e.action == MotionEvent.ACTION_MOVE) {
|
} else if (e.action == MotionEvent.ACTION_MOVE) {
|
||||||
val dx = e.x - initialX
|
val dx = e.x - initialX
|
||||||
|
|
|
@ -467,7 +467,7 @@ class StatusViewHolder(val binding: PostFragmentBinding) : RecyclerView.ViewHold
|
||||||
|
|
||||||
//Activate double tap liking
|
//Activate double tap liking
|
||||||
var clicked = false
|
var clicked = false
|
||||||
binding.postPager.setOnClickListener {
|
binding.postPagerHost.doubleTapCallback = {
|
||||||
lifecycleScope.launchWhenCreated {
|
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) {
|
||||||
|
|
Loading…
Reference in New Issue