[Android] Get rid of the WeakHandler class

Nicolas Pomepuy git at videolan.org
Tue Jul 25 14:57:29 UTC 2023


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Thu Jul 20 12:56:14 2023 +0200| [5b6882a612ff7f1a1694c1bc8a6b899bd7acf653] | committer: Duncan McNamara

Get rid of the WeakHandler class

> https://code.videolan.org/videolan/vlc-android/commit/5b6882a612ff7f1a1694c1bc8a6b899bd7acf653
---

 .../main/java/org/videolan/tools/WeakHandler.kt    | 34 ----------------------
 .../videolan/vlc/gui/video/VideoDelayDelegate.kt   |  8 ++---
 2 files changed, 4 insertions(+), 38 deletions(-)

diff --git a/application/tools/src/main/java/org/videolan/tools/WeakHandler.kt b/application/tools/src/main/java/org/videolan/tools/WeakHandler.kt
deleted file mode 100644
index f08c8ae9f2..0000000000
--- a/application/tools/src/main/java/org/videolan/tools/WeakHandler.kt
+++ /dev/null
@@ -1,34 +0,0 @@
-/*****************************************************************************
- * WeakHandler.java
- *
- * Copyright © 2012 VLC authors and VideoLAN
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- */
-
-package org.videolan.tools
-
-import android.os.Handler
-import android.os.Looper
-
-import java.lang.ref.WeakReference
-
-abstract class WeakHandler<T>(owner: T) : Handler(Looper.getMainLooper()) {
-    private val mOwner: WeakReference<T> = WeakReference(owner)
-
-    val owner: T?
-        get() = mOwner.get()
-
-}
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 6e464b29f7..3bfa982a80 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))
-        playbackSettingPlus.setOnTouchListener(OnRepeatListenerTouch(this))
-        playbackSettingMinus.setOnKeyListener(OnRepeatListenerKey(this))
-        playbackSettingPlus.setOnKeyListener(OnRepeatListenerKey(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.setVisible()
         close.setVisible()
         playbackSettingPlus.setVisible()



More information about the Android mailing list