[Android] Add a third speed to the repeat listeners
Nicolas Pomepuy
git at videolan.org
Wed Jun 5 14:57:37 UTC 2024
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Thu May 2 13:39:33 2024 +0200| [676d062f2d805154ffe2a7455014ba750bc50ed4] | committer: Duncan McNamara
Add a third speed to the repeat listeners
> https://code.videolan.org/videolan/vlc-android/commit/676d062f2d805154ffe2a7455014ba750bc50ed4
---
.../src/org/videolan/vlc/gui/helpers/OnRepeatListener.kt | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/helpers/OnRepeatListener.kt b/application/vlc-android/src/org/videolan/vlc/gui/helpers/OnRepeatListener.kt
index 2b37c64c26..3ee8ea6f53 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/helpers/OnRepeatListener.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/helpers/OnRepeatListener.kt
@@ -30,6 +30,7 @@ import androidx.lifecycle.Lifecycle
import org.videolan.vlc.BuildConfig
import org.videolan.vlc.util.LifecycleAwareScheduler
import org.videolan.vlc.util.SchedulerCallback
+import kotlin.math.pow
/**
*
@@ -82,7 +83,11 @@ open class OnRepeatListener(private val initialInterval: Int, private val normal
override fun onTaskTriggered(id: String, data: Bundle) {
when(id) {
ACTION_ONCLICK -> {
- val interval = if (initialTime > -1L && System.currentTimeMillis() - initialTime > speedUpDelay) normalInterval.toLong() / 3 else normalInterval.toLong()
+ val interval = if (initialTime > -1L && System.currentTimeMillis() - initialTime > speedUpDelay) {
+ val speedWeight = if (System.currentTimeMillis() - initialTime < speedUpDelay * 2) 1 else 2
+ if (BuildConfig.DEBUG) Log.d("RepeatSpeed", "From start: ${System.currentTimeMillis() - initialTime}ms. speedWeight: $speedWeight. Interval: ${normalInterval.toLong() / (3F.pow(speedWeight.toInt())).toInt()}")
+ normalInterval.toLong() / (3F.pow(speedWeight)).toInt()
+ } else normalInterval.toLong()
scheduler.scheduleAction(ACTION_ONCLICK, interval)
clickListener.onClick(downView)
}
More information about the Android
mailing list