fix some animation f***

This commit is contained in:
Christian Schabesberger 2024-08-09 13:41:31 +02:00
parent 3dedd98b2a
commit 0d6227071e
2 changed files with 7 additions and 10 deletions

View File

@ -94,7 +94,6 @@ fun FullscreenGestureUI(
GestureSurface(
modifier = Modifier
.weight(1f),
multiTapTimeoutInMs = FAST_SEEK_MODE_DURATION,
onRegularTap = defaultOnRegularTap,
onMultiTap = {
println("multitap ${-it}")
@ -133,7 +132,6 @@ fun FullscreenGestureUI(
modifier = Modifier
.weight(1f),
onRegularTap = defaultOnRegularTap,
multiTapTimeoutInMs = FAST_SEEK_MODE_DURATION,
onMovement = { movement ->
if (0 < movement.y) {
switchToEmbeddedView()
@ -144,7 +142,6 @@ fun FullscreenGestureUI(
modifier = Modifier
.weight(1f),
onRegularTap = defaultOnRegularTap,
multiTapTimeoutInMs = FAST_SEEK_MODE_DURATION,
onMultiTap = fastSeek,
onMultiTapFinished = fastSeekFinished,
onUp = {

View File

@ -37,13 +37,13 @@ import androidx.compose.ui.input.pointer.pointerInteropFilter
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import net.newpipe.newplayer.ui.videoplayer.DELAY_UNTIL_SHOWING_UI_AFTER_TOUCH_IN_MS
@Composable
@OptIn(ExperimentalComposeUiApi::class)
fun GestureSurface(
modifier: Modifier,
color: Color = Color.Transparent,
multiTapTimeoutInMs: Long,
onMultiTap: (Int) -> Unit = {},
onMultiTapFinished: () -> Unit = {},
onRegularTap: () -> Unit = {},
@ -59,7 +59,7 @@ fun GestureSurface(
mutableStateOf(TouchedPosition(0f, 0f))
}
var lastTouchTime by remember {
var lastFingerUpTime by remember {
mutableStateOf(System.currentTimeMillis())
}
@ -86,26 +86,26 @@ fun GestureSurface(
onUp()
val currentTime = System.currentTimeMillis()
if (!moveOccured) {
val timeSinceLastTouch = currentTime - lastTouchTime
if (timeSinceLastTouch <= multiTapTimeoutInMs) {
val timeSinceLastTouch = currentTime - lastFingerUpTime
if (timeSinceLastTouch <= DELAY_UNTIL_SHOWING_UI_AFTER_TOUCH_IN_MS) {
regularTabJob?.cancel()
cancelMultitapJob?.cancel()
multitapAmount++
onMultiTap(multitapAmount)
cancelMultitapJob = composableScope.launch {
delay(multiTapTimeoutInMs)
delay(DELAY_UNTIL_SHOWING_UI_AFTER_TOUCH_IN_MS)
multitapAmount = 0
onMultiTapFinished()
}
} else {
regularTabJob = composableScope.launch {
delay(multiTapTimeoutInMs)
delay(DELAY_UNTIL_SHOWING_UI_AFTER_TOUCH_IN_MS)
onRegularTap()
}
}
}
moveOccured = false
lastTouchTime = currentTime
lastFingerUpTime = currentTime
true
}