[Android] Code cleaning

Geoffrey Métais git at videolan.org
Thu Apr 16 15:43:16 CEST 2020


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Mar 30 12:32:26 2020 +0200| [e331834c2be7d36f13bc0a866787606c0e15a0ff] | committer: Nicolas Pomepuy

Code cleaning

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

 .../org/videolan/vlc/gui/browser/BrowserContainer.kt | 20 ++++++++++++++++++++
 .../videolan/vlc/gui/browser/MainBrowserFragment.kt  | 16 ++++++++--------
 .../org/videolan/vlc/interfaces/IEventsHandler.kt    |  3 +--
 3 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/browser/BrowserContainer.kt b/application/vlc-android/src/org/videolan/vlc/gui/browser/BrowserContainer.kt
index 02ff91b8d..f232d1431 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/browser/BrowserContainer.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/browser/BrowserContainer.kt
@@ -25,6 +25,8 @@
 package org.videolan.vlc.gui.browser
 
 import android.app.Activity
+import android.view.View
+import androidx.recyclerview.widget.RecyclerView
 import org.videolan.vlc.interfaces.IEventsHandler
 
 interface BrowserContainer<T> : IEventsHandler<T> {
@@ -36,4 +38,22 @@ interface BrowserContainer<T> : IEventsHandler<T> {
     val isNetwork: Boolean
     val isFile: Boolean
     val inCards: Boolean
+}
+
+class BrowserContainerImpl<T>(
+        override val scannedDirectory: Boolean,
+        override val mrl: String?,
+        override val isRootDirectory: Boolean,
+        override val isNetwork: Boolean,
+        override val isFile: Boolean,
+        override val inCards: Boolean
+) : BrowserContainer<T> {
+    override fun containerActivity() = throw NotImplementedError()
+    override fun onClick(v: View, position: Int, item: T) {}
+    override fun onLongClick(v: View, position: Int, item: T) = false
+    override fun onImageClick(v: View, position: Int, item: T) {}
+    override fun onCtxClick(v: View, position: Int, item: T) {}
+    override fun onUpdateFinished(adapter: RecyclerView.Adapter<*>) {}
+    override fun onMainActionClick(v: View, position: Int, item: T) {}
+    override fun onItemFocused(v: View, item: T) {}
 }
\ No newline at end of file
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/browser/MainBrowserFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/browser/MainBrowserFragment.kt
index b72622747..2131f65b2 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/browser/MainBrowserFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/browser/MainBrowserFragment.kt
@@ -208,7 +208,14 @@ class MainBrowserFragment : BaseFragment(), View.OnClickListener, CtxActionRecei
         dialog.show(fm, "fragment_add_server")
     }
 
-    inner class MainBrowserContainer(override val scannedDirectory: Boolean = false, override val mrl: String? = null, override val isRootDirectory: Boolean = true, override val isNetwork: Boolean, override val isFile: Boolean, override val inCards: Boolean = true) : BrowserContainer<MediaLibraryItem> {
+    inner class MainBrowserContainer(
+            override val scannedDirectory: Boolean = false,
+            override val mrl: String? = null,
+            override val isRootDirectory: Boolean = true,
+            override val isNetwork: Boolean,
+            override val isFile: Boolean,
+            override val inCards: Boolean = true
+    ) : BrowserContainer<MediaLibraryItem> by BrowserContainerImpl(scannedDirectory, mrl, isRootDirectory, isNetwork, isFile, inCards) {
         override fun containerActivity() = requireActivity()
 
         fun requireAdapter() = containerAdapterAssociation[this]?.first
@@ -293,13 +300,6 @@ class MainBrowserFragment : BaseFragment(), View.OnClickListener, CtxActionRecei
                 }
             }
         }
-
-        override fun onUpdateFinished(adapter: RecyclerView.Adapter<*>) {
-        }
-
-        override fun onMainActionClick(v: View, position: Int, item: MediaLibraryItem) {}
-
-        override fun onItemFocused(v: View, item: MediaLibraryItem) {}
     }
 
     override fun onCtxAction(position: Int, option: Int) {
diff --git a/application/vlc-android/src/org/videolan/vlc/interfaces/IEventsHandler.kt b/application/vlc-android/src/org/videolan/vlc/interfaces/IEventsHandler.kt
index 757c1efd1..f56ca6393 100644
--- a/application/vlc-android/src/org/videolan/vlc/interfaces/IEventsHandler.kt
+++ b/application/vlc-android/src/org/videolan/vlc/interfaces/IEventsHandler.kt
@@ -2,7 +2,6 @@ package org.videolan.vlc.interfaces
 
 import android.view.View
 import androidx.recyclerview.widget.RecyclerView
-import org.videolan.medialibrary.media.MediaLibraryItem
 
 interface IEventsHandler<T> {
     fun onClick(v: View, position: Int, item: T)
@@ -12,4 +11,4 @@ interface IEventsHandler<T> {
     fun onUpdateFinished(adapter: RecyclerView.Adapter<*>)
     fun onMainActionClick(v: View, position: Int, item: T)
     fun onItemFocused(v: View, item: T)
-}
+}
\ No newline at end of file



More information about the Android mailing list