[Android] Simplify 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:33:38 2024 +0200| [02d58048780a5815de9c821cfdd5c8b966f095ea] | committer: Duncan McNamara
Simplify the repeat listeners
> https://code.videolan.org/videolan/vlc-android/commit/02d58048780a5815de9c821cfdd5c8b966f095ea
---
.../src/org/videolan/vlc/gui/dialogs/PlaybackSpeedDialog.kt | 8 ++++----
.../src/org/videolan/vlc/gui/helpers/OnRepeatListenerKey.kt | 8 +-------
.../src/org/videolan/vlc/gui/helpers/OnRepeatListenerTouch.kt | 7 +------
.../src/org/videolan/vlc/gui/video/VideoDelayDelegate.kt | 8 ++++----
.../src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt | 4 ++--
5 files changed, 12 insertions(+), 23 deletions(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/PlaybackSpeedDialog.kt b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/PlaybackSpeedDialog.kt
index 7f634af001..08b2bc03bb 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/PlaybackSpeedDialog.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/PlaybackSpeedDialog.kt
@@ -104,10 +104,10 @@ class PlaybackSpeedDialog : VLCBottomSheetDialogFragment() {
binding.playbackSpeedSeek.setOnSeekBarChangeListener(seekBarListener)
binding.playbackSpeedValue.setOnClickListener(resetListener)
- binding.buttonSpeedMinus.setOnTouchListener(OnRepeatListenerTouch(speedDownListener, lifecycle))
- binding.buttonSpeedPlus.setOnTouchListener(OnRepeatListenerTouch(speedUpListener, lifecycle))
- binding.buttonSpeedMinus.setOnKeyListener(OnRepeatListenerKey(speedDownListener, lifecycle))
- binding.buttonSpeedPlus.setOnKeyListener(OnRepeatListenerKey(speedUpListener, lifecycle))
+ binding.buttonSpeedMinus.setOnTouchListener(OnRepeatListenerTouch(clickListener = speedDownListener, listenerLifecycle = lifecycle))
+ binding.buttonSpeedPlus.setOnTouchListener(OnRepeatListenerTouch(clickListener = speedUpListener, listenerLifecycle = lifecycle))
+ binding.buttonSpeedMinus.setOnKeyListener(OnRepeatListenerKey(clickListener = speedDownListener, listenerLifecycle = lifecycle))
+ binding.buttonSpeedPlus.setOnKeyListener(OnRepeatListenerKey(clickListener = speedUpListener, listenerLifecycle = lifecycle))
binding.buttonSpeed1.setOnClickListener {
changeSpeedTo(1F)
}
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/helpers/OnRepeatListenerKey.kt b/application/vlc-android/src/org/videolan/vlc/gui/helpers/OnRepeatListenerKey.kt
index 3705eee01b..842f95de76 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/helpers/OnRepeatListenerKey.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/helpers/OnRepeatListenerKey.kt
@@ -35,13 +35,7 @@ import androidx.lifecycle.Lifecycle
* @param normalInterval Normal interval in millis
* @param clickListener The OnClickListener to trigger
*/
-class OnRepeatListenerKey(private val initialInterval: Int, private val normalInterval: Int, speedUpDelay: Int, private val clickListener: View.OnClickListener, listenerLifecycle: Lifecycle) : View.OnKeyListener, OnRepeatListener(initialInterval, normalInterval, speedUpDelay, clickListener, listenerLifecycle) {
-
- /**
- *
- * @param clickListener The OnClickListener to trigger
- */
- constructor(clickListener: View.OnClickListener, listenerLifecycle: Lifecycle) : this(DEFAULT_INITIAL_DELAY, DEFAULT_NORMAL_DELAY, DEFAULT_SPEEDUP_DELAY, clickListener, listenerLifecycle)
+class OnRepeatListenerKey(private val initialInterval: Int = DEFAULT_INITIAL_DELAY, private val normalInterval: Int = DEFAULT_NORMAL_DELAY, speedUpDelay: Int = DEFAULT_SPEEDUP_DELAY, private val clickListener: View.OnClickListener, listenerLifecycle: Lifecycle) : View.OnKeyListener, OnRepeatListener(initialInterval, normalInterval, speedUpDelay, clickListener, listenerLifecycle) {
override fun onKey(view: View?, keyCode: Int, event: KeyEvent?): Boolean {
if (view == null || event == null) return false
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/helpers/OnRepeatListenerTouch.kt b/application/vlc-android/src/org/videolan/vlc/gui/helpers/OnRepeatListenerTouch.kt
index bd132be245..80782c009c 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/helpers/OnRepeatListenerTouch.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/helpers/OnRepeatListenerTouch.kt
@@ -34,12 +34,7 @@ import androidx.lifecycle.Lifecycle
* @param normalInterval Normal interval in millis
* @param clickListener The OnClickListener to trigger
*/
-class OnRepeatListenerTouch(private val initialInterval: Int, private val normalInterval: Int, speedUpDelay: Int, private val clickListener: View.OnClickListener, listenerLifecycle: Lifecycle) : View.OnTouchListener, OnRepeatListener(initialInterval, normalInterval, speedUpDelay, clickListener, listenerLifecycle) {
- /**
- *
- * @param clickListener The OnClickListener to trigger
- */
- constructor(clickListener: View.OnClickListener, listenerLifecycle: Lifecycle) : this(DEFAULT_INITIAL_DELAY, DEFAULT_NORMAL_DELAY, DEFAULT_SPEEDUP_DELAY, clickListener, listenerLifecycle)
+class OnRepeatListenerTouch(private val initialInterval: Int = DEFAULT_INITIAL_DELAY, private val normalInterval: Int = DEFAULT_NORMAL_DELAY, speedUpDelay: Int = DEFAULT_SPEEDUP_DELAY, private val clickListener: View.OnClickListener, listenerLifecycle: Lifecycle) : View.OnTouchListener, OnRepeatListener(initialInterval, normalInterval, speedUpDelay, clickListener, listenerLifecycle) {
override fun onTouch(view: View, motionEvent: MotionEvent): Boolean {
when (motionEvent.action) {
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoDelayDelegate.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoDelayDelegate.kt
index 3bfa982a80..6eaa75ebb7 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoDelayDelegate.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoDelayDelegate.kt
@@ -109,10 +109,10 @@ class VideoDelayDelegate(private val player: VideoPlayerActivity) : View.OnClick
delayApplyAll.setOnClickListener(this)
delayApplyBt.setOnClickListener(this)
close.setOnClickListener(this)
- playbackSettingMinus.setOnTouchListener(OnRepeatListenerTouch(this, player.lifecycle))
- playbackSettingPlus.setOnTouchListener(OnRepeatListenerTouch(this, player.lifecycle))
- playbackSettingMinus.setOnKeyListener(OnRepeatListenerKey(this, player.lifecycle))
- playbackSettingPlus.setOnKeyListener(OnRepeatListenerKey(this, player.lifecycle))
+ playbackSettingMinus.setOnTouchListener(OnRepeatListenerTouch(clickListener = this, listenerLifecycle = player.lifecycle))
+ playbackSettingPlus.setOnTouchListener(OnRepeatListenerTouch(clickListener = this, listenerLifecycle = player.lifecycle))
+ playbackSettingMinus.setOnKeyListener(OnRepeatListenerKey(clickListener = this, listenerLifecycle = player.lifecycle))
+ playbackSettingPlus.setOnKeyListener(OnRepeatListenerKey(clickListener = this, listenerLifecycle = player.lifecycle))
playbackSettingMinus.setVisible()
close.setVisible()
playbackSettingPlus.setVisible()
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt
index 1c2321ffd1..0c3ca55ff7 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt
@@ -661,8 +661,8 @@ class VideoPlayerOverlayDelegate (private val player: VideoPlayerActivity) {
hudBinding.playerOverlayForward.setOnClickListener(player)
hudBinding.playerOverlayRewind.setOnLongClickListener(player)
hudBinding.playerOverlayForward.setOnLongClickListener(player)
- hudBinding.playerOverlayRewind.setOnKeyListener(OnRepeatListenerKey(player, player.lifecycle))
- hudBinding.playerOverlayForward.setOnKeyListener(OnRepeatListenerKey(player, player.lifecycle))
+ hudBinding.playerOverlayRewind.setOnKeyListener(OnRepeatListenerKey(clickListener = player, listenerLifecycle = player.lifecycle))
+ hudBinding.playerOverlayForward.setOnKeyListener(OnRepeatListenerKey(clickListener = player, listenerLifecycle = player.lifecycle))
}
fun updateOrientationIcon() {
More information about the Android
mailing list