[Android] Browser: code cleaning

Geoffrey Métais git at videolan.org
Fri Jul 5 14:07:45 CEST 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Jul  5 12:28:28 2019 +0200| [e91e9d1eb8534301a205da856694376a95dec821] | committer: Geoffrey Métais

Browser: code cleaning

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

 .../vlc/gui/browser/BaseBrowserFragment.kt         | 31 +++++++++++-----------
 .../vlc/gui/browser/MediaBrowserFragment.kt        |  1 -
 2 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
index 2a4d134d2..45f961a3d 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
@@ -233,23 +233,22 @@ abstract class BaseBrowserFragment : MediaBrowserFragment<BrowserModel>(), IRefr
      * Update views visibility and emptiness info
      */
     protected open fun updateEmptyView() {
-        if (swipeRefreshLayout == null) return
-        if (Util.isListEmpty(viewModel.dataset.value)) {
-            if (swipeRefreshLayout != null) {
-                if (swipeRefreshLayout!!.isRefreshing) {
-                    binding.empty.setText(R.string.loading)
-                    binding.empty.visibility = View.VISIBLE
-                    binding.networkList.visibility = View.GONE
-                } else {
-                    binding.empty.setText(R.string.directory_empty)
-                    binding.empty.visibility = View.VISIBLE
-                    binding.networkList.visibility = View.GONE
+            swipeRefreshLayout?.let {
+                if (Util.isListEmpty(viewModel.dataset.value)) {
+                    if (it.isRefreshing) {
+                        binding.empty.setText(R.string.loading)
+                        binding.empty.visibility = View.VISIBLE
+                        binding.networkList.visibility = View.GONE
+                    } else {
+                        binding.empty.setText(R.string.directory_empty)
+                        binding.empty.visibility = View.VISIBLE
+                        binding.networkList.visibility = View.GONE
+                    }
+                } else if (binding.empty.visibility == View.VISIBLE) {
+                    binding.empty.visibility = View.GONE
+                    binding.networkList.visibility = View.VISIBLE
                 }
             }
-        } else if (binding.empty.visibility == View.VISIBLE) {
-            binding.empty.visibility = View.GONE
-            binding.networkList.visibility = View.VISIBLE
-        }
     }
 
     override fun refresh() = viewModel.refresh()
@@ -477,7 +476,7 @@ abstract class BaseBrowserFragment : MediaBrowserFragment<BrowserModel>(), IRefr
     override fun onMainActionClick(v: View, position: Int, item: MediaLibraryItem) {}
 
     override fun onUpdateFinished(adapter: RecyclerView.Adapter<*>) {
-        if (swipeRefreshLayout != null) swipeRefreshLayout!!.isRefreshing = false
+        swipeRefreshLayout?.isRefreshing = false
         handler.sendEmptyMessage(MSG_HIDE_LOADING)
         updateEmptyView()
         if (!Util.isListEmpty(viewModel.dataset.value)) {
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.kt b/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.kt
index 2ecd01487..ca093c158 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.kt
@@ -44,7 +44,6 @@ import org.videolan.medialibrary.interfaces.media.AbstractPlaylist
 import org.videolan.medialibrary.media.MediaLibraryItem
 import org.videolan.tools.isStarted
 import org.videolan.vlc.R
-import org.videolan.vlc.VLCApplication
 import org.videolan.vlc.gui.AudioPlayerContainerActivity
 import org.videolan.vlc.gui.ContentActivity
 import org.videolan.vlc.gui.InfoActivity



More information about the Android mailing list