[Android] Disable pull-to-refresh on file browser root level

Geoffrey Métais git at videolan.org
Thu Aug 9 13:36:25 CEST 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Aug  9 13:36:00 2018 +0200| [512ff925bc17c2de280cd1a1f21608d7e7856889] | committer: Geoffrey Métais

Disable pull-to-refresh on file browser root level

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

 vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt | 5 ++++-
 .../src/org/videolan/vlc/gui/browser/FileBrowserFragment.java       | 6 ++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

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 4e7b39596..9e0140dc9 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
@@ -130,10 +130,13 @@ abstract class BaseBrowserFragment : MediaBrowserFragment<BrowserModel>(), IRefr
         layoutManager = LinearLayoutManager(activity)
         binding.networkList.layoutManager = layoutManager
         binding.networkList.adapter = adapter
-        mSwipeRefreshLayout.setOnRefreshListener(this)
+        registerSwiperRefreshlayout()
         viewModel.dataset.observe(this, Observer<MutableList<MediaLibraryItem>> { mediaLibraryItems -> adapter.update(mediaLibraryItems!!) })
         viewModel.getDescriptionUpdate().observe(this, Observer { pair -> if (pair != null) adapter.notifyItemChanged(pair.first, pair.second) })
     }
+
+    open fun registerSwiperRefreshlayout() = mSwipeRefreshLayout.setOnRefreshListener(this)
+
     override fun setBreadcrumb() {
         val ariane = requireActivity().findViewById<RecyclerView>(R.id.ariane) ?: return
         val media = currentMedia
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/FileBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/FileBrowserFragment.java
index 7f3cf55c0..db5abd79b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/FileBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/FileBrowserFragment.java
@@ -63,6 +63,12 @@ public class FileBrowserFragment extends BaseBrowserFragment {
         setupBrowser();
     }
 
+    @Override
+    public void registerSwiperRefreshlayout() {
+        if (!isRootDirectory()) super.registerSwiperRefreshlayout();
+        else mSwipeRefreshLayout.setEnabled(false);
+    }
+
     protected void setupBrowser() {
         if (isRootDirectory()) viewModel = ViewModelProviders.of(requireActivity(), new BrowserModel.Factory(requireContext(), null, BrowserModelKt.TYPE_FILE, getShowHiddenFiles())).get(BrowserModel.class);
         else viewModel = ViewModelProviders.of(this, new BrowserModel.Factory(requireContext(), getMrl(), BrowserModelKt.TYPE_FILE, getShowHiddenFiles())).get(BrowserModel.class);



More information about the Android mailing list