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

View File

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