[Android] Fix loading states when coming from the Local Network fragment

Nicolas Pomepuy git at videolan.org
Mon Jul 29 16:37:09 CEST 2019


vlc-android | branch: 3.2.x | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Fri Jul 26 11:28:43 2019 +0200| [0a1a9d8dafb5215733338c462c3dc48c445308e5] | committer: Geoffrey Métais

Fix loading states when coming from the Local Network fragment

(cherry picked from commit 7d511d0cd739a45d59bbd08283bf6c668623c12c)

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

 vlc-android/src/org/videolan/vlc/gui/HistoryFragment.kt          | 3 +++
 vlc-android/src/org/videolan/vlc/gui/network/MRLPanelFragment.kt | 4 ++++
 vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt  | 3 +++
 3 files changed, 10 insertions(+)

diff --git a/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.kt b/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.kt
index 0f896f610..075d0550c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.kt
@@ -69,6 +69,9 @@ class HistoryFragment : MediaBrowserFragment<HistoryModel>(), IRefreshable, IHis
                 updateEmptyView()
             }
         })
+        viewModel.loading.observe(this, Observer {
+            (activity as? MainActivity)?.refreshing = it
+        })
     }
 
     override fun onStart() {
diff --git a/vlc-android/src/org/videolan/vlc/gui/network/MRLPanelFragment.kt b/vlc-android/src/org/videolan/vlc/gui/network/MRLPanelFragment.kt
index 7344b34b2..dbed6dd4c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/network/MRLPanelFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/network/MRLPanelFragment.kt
@@ -48,6 +48,7 @@ import org.videolan.medialibrary.interfaces.media.AbstractMediaWrapper
 import org.videolan.tools.coroutineScope
 import org.videolan.vlc.R
 import org.videolan.vlc.databinding.MrlPanelBinding
+import org.videolan.vlc.gui.MainActivity
 import org.videolan.vlc.gui.dialogs.CtxActionReceiver
 import org.videolan.vlc.gui.dialogs.SavePlaylistDialog
 import org.videolan.vlc.gui.dialogs.showContext
@@ -118,6 +119,9 @@ class MRLPanelFragment : Fragment(), View.OnKeyListener, TextView.OnEditorAction
     override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
         super.onViewCreated(view, savedInstanceState)
         viewModel.dataset.observe(this, Observer { adapter.setList(it as List<AbstractMediaWrapper>) })
+        viewModel.loading.observe(this, Observer {
+            (activity as? MainActivity)?.refreshing = it
+        })
     }
 
     override fun onStart() {
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
index 0da1d2cfb..bf4bcf9cc 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
@@ -45,6 +45,7 @@ import org.videolan.medialibrary.media.MediaLibraryItem
 import org.videolan.tools.MultiSelectHelper
 import org.videolan.vlc.R
 import org.videolan.vlc.databinding.VideoGridBinding
+import org.videolan.vlc.gui.MainActivity
 import org.videolan.vlc.gui.SecondaryActivity
 import org.videolan.vlc.gui.browser.MediaBrowserFragment
 import org.videolan.vlc.gui.dialogs.CtxActionReceiver
@@ -110,6 +111,8 @@ class VideoGridFragment : MediaBrowserFragment<VideosViewModel>(), SwipeRefreshL
             viewModel.provider.loading.observe(this, Observer { loading ->
                 if (loading) handler.sendEmptyMessageDelayed(SET_REFRESHING, 300L)
                 else handler.sendEmptyMessage(UNSET_REFRESHING)
+                (activity as? MainActivity)?.refreshing = loading
+
             })
             AbstractMedialibrary.lastThumb.observe(this, thumbObs)
         }



More information about the Android mailing list