[Android] Refactor the swipe filter

Nicolas Pomepuy git at videolan.org
Tue Oct 25 06:38:26 UTC 2022


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Oct 11 08:01:44 2022 +0200| [8ff29c0f5d1d5164321ec6750ce338382ff96cf6] | committer: Nicolas Pomepuy

Refactor the swipe filter

> https://code.videolan.org/videolan/vlc-android/commit/8ff29c0f5d1d5164321ec6750ce338382ff96cf6
---

 application/vlc-android/src/org/videolan/vlc/gui/BaseFragment.kt  | 8 ++++++++
 .../src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.kt    | 8 --------
 .../src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt        | 8 --------
 3 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/BaseFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/BaseFragment.kt
index 886ef35cf..2d311ee7d 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/BaseFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/BaseFragment.kt
@@ -6,6 +6,7 @@ import android.graphics.Color
 import android.os.Bundle
 import android.util.TypedValue
 import android.view.Menu
+import android.view.MotionEvent
 import android.view.View
 import androidx.appcompat.app.AppCompatActivity
 import androidx.appcompat.view.ActionMode
@@ -31,6 +32,13 @@ abstract class BaseFragment : Fragment(), ActionMode.Callback {
     var actionMode: ActionMode? = null
     var fabPlay: FloatingActionButton? = null
     lateinit var swipeRefreshLayout: SwipeRefreshLayout
+    /*
+     * Disable Swipe Refresh while scrolling horizontally
+     */
+    val swipeFilter = View.OnTouchListener { _, event ->
+        swipeRefreshLayout.isEnabled = event.action == MotionEvent.ACTION_UP
+        false
+    }
     open val hasTabs = false
 
     private var refreshJob : Job? = null
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.kt
index 43531b36e..37321f017 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.kt
@@ -69,14 +69,6 @@ class AudioAlbumsSongsFragment : BaseAudioBrowser<AlbumSongsViewModel>(), SwipeR
 
     override val hasTabs = true
 
-    /*
-     * Disable Swipe Refresh while scrolling horizontally
-     */
-    private val swipeFilter = View.OnTouchListener { _, event ->
-        swipeRefreshLayout.isEnabled = event.action == MotionEvent.ACTION_UP
-        false
-    }
-
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
 
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt
index 5a3bf4ff4..76188d317 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt
@@ -80,14 +80,6 @@ class AudioBrowserFragment : BaseAudioBrowser<AudioBrowserViewModel>() {
     private var spacing = 0
     private var restorePositions: SparseArray<Int> = SparseArray()
 
-    /*
-     * Disable Swipe Refresh while scrolling horizontally
-     */
-    private val swipeFilter = View.OnTouchListener { _, event ->
-        swipeRefreshLayout.isEnabled = event.action == MotionEvent.ACTION_UP
-        false
-    }
-
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
         spacing = requireActivity().resources.getDimension(R.dimen.kl_small).toInt()



More information about the Android mailing list