[Android] Fix an incorrect loading state in the video screen

Nicolas Pomepuy git at videolan.org
Tue Nov 15 13:35:02 UTC 2022


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Nov 15 13:23:32 2022 +0100| [d32c9f51cf462839d4d6b508ad533c003ad4ef8d] | committer: Duncan McNamara

Fix an incorrect loading state in the video screen

Fixes #2739

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

 .../vlc-android/res/layout/video_browser.xml       | 25 ++++++--------------
 .../src/org/videolan/vlc/gui/PlaylistFragment.kt   |  2 +-
 .../videolan/vlc/gui/video/VideoBrowserFragment.kt | 27 +---------------------
 .../videolan/vlc/gui/video/VideoGridFragment.kt    |  2 +-
 4 files changed, 10 insertions(+), 46 deletions(-)

diff --git a/application/vlc-android/res/layout/video_browser.xml b/application/vlc-android/res/layout/video_browser.xml
index 9475f135e7..345d9177c7 100644
--- a/application/vlc-android/res/layout/video_browser.xml
+++ b/application/vlc-android/res/layout/video_browser.xml
@@ -1,5 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
   ~ *************************************************************************
   ~  video_browser.xml
   ~ **************************************************************************
@@ -36,24 +35,14 @@
             app:layout_constraintRight_toRightOf="parent"
             app:layout_constraintTop_toTopOf="parent" />
 
-    <org.videolan.vlc.gui.view.SwipeRefreshLayout
-            android:id="@+id/swipeLayout"
+    <androidx.viewpager.widget.ViewPager
+            android:id="@+id/pager"
             android:layout_width="match_parent"
-            android:layout_height="0dp"
+            android:layout_height="match_parent"
+            android:layout_marginLeft="4dp"
+            android:layout_marginRight="4dp"
             app:layout_constraintBottom_toBottomOf="parent"
-            app:layout_constraintLeft_toLeftOf="parent"
-            app:layout_constraintRight_toRightOf="parent"
-            app:layout_constraintTop_toBottomOf="@+id/searchButton">
-
-        <androidx.viewpager.widget.ViewPager
-                android:id="@+id/pager"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:layout_marginLeft="4dp"
-                android:layout_marginRight="4dp"
-                app:layout_constraintBottom_toBottomOf="parent"
-                app:layout_constraintTop_toBottomOf="@+id/searchButton"/>
-    </org.videolan.vlc.gui.view.SwipeRefreshLayout>
+            app:layout_constraintTop_toBottomOf="@+id/searchButton" />
 
     <org.videolan.vlc.gui.view.FastScroller
             android:id="@+id/songs_fast_scroller"
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/PlaylistFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/PlaylistFragment.kt
index 3cb4a1054c..aa80b4835d 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/PlaylistFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/PlaylistFragment.kt
@@ -109,7 +109,7 @@ class PlaylistFragment : BaseAudioBrowser<PlaylistsViewModel>(), SwipeRefreshLay
             updateEmptyView()
         }
         viewModel.provider.loading.observe(requireActivity()) { loading ->
-            setRefreshing(loading) { }
+            if (isResumed) setRefreshing(loading) { }
         }
 
         viewModel.provider.liveHeaders.observe(requireActivity()) {
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoBrowserFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoBrowserFragment.kt
index b71cf88923..38f0cc3e6d 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoBrowserFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoBrowserFragment.kt
@@ -22,26 +22,6 @@
  *
  */
 
-/*****************************************************************************
- * VideoGridFragment.kt
- *
- * Copyright © 2019 VLC authors and VideoLAN
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- */
-
 package org.videolan.vlc.gui.video
 
 import android.os.Bundle
@@ -50,7 +30,6 @@ import androidx.appcompat.view.ActionMode
 import androidx.fragment.app.Fragment
 import androidx.fragment.app.FragmentManager
 import androidx.fragment.app.FragmentPagerAdapter
-import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
 import androidx.viewpager.widget.ViewPager
 import com.google.android.material.tabs.TabLayout
 import org.videolan.medialibrary.interfaces.media.Playlist
@@ -65,7 +44,7 @@ import org.videolan.vlc.interfaces.Filterable
  * Fragment containing the video viewpager
  *
  */
-class VideoBrowserFragment : BaseFragment(), SwipeRefreshLayout.OnRefreshListener, TabLayout.OnTabSelectedListener, ViewPager.OnPageChangeListener, Filterable {
+class VideoBrowserFragment : BaseFragment(), TabLayout.OnTabSelectedListener, ViewPager.OnPageChangeListener, Filterable {
     override fun getTitle() = getString(R.string.videos)
     private lateinit var videoPagerAdapter: VideoPagerAdapter
     private lateinit var layoutOnPageChangeListener: TabLayout.TabLayoutOnPageChangeListener
@@ -88,7 +67,6 @@ class VideoBrowserFragment : BaseFragment(), SwipeRefreshLayout.OnRefreshListene
         viewPager = view.findViewById(R.id.pager)
         videoPagerAdapter = VideoPagerAdapter(fragmentManager = childFragmentManager)
         viewPager.adapter = videoPagerAdapter
-        viewPager.setOnTouchListener(swipeFilter)
     }
 
     override fun onStart() {
@@ -107,8 +85,6 @@ class VideoBrowserFragment : BaseFragment(), SwipeRefreshLayout.OnRefreshListene
 
     override fun onDestroyActionMode(mode: ActionMode?) {}
 
-    override fun onRefresh() {}
-
     override fun onTabSelected(tab: TabLayout.Tab) { }
 
     override fun onTabUnselected(tab: TabLayout.Tab) {
@@ -122,7 +98,6 @@ class VideoBrowserFragment : BaseFragment(), SwipeRefreshLayout.OnRefreshListene
         reopenSearchIfNeeded()
     }
 
-
     /**
      * Reopens the search if the tab is changed
      *
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
index 45c812b892..3c900bf6ea 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
@@ -131,7 +131,7 @@ class VideoGridFragment : MediaBrowserFragment<VideosViewModel>(), SwipeRefreshL
     private fun setDataObservers() {
         videoListAdapter.dataType = viewModel.groupingType
         viewModel.provider.loading.observe(this at VideoGridFragment) { loading ->
-            setRefreshing(loading) { refresh ->
+            if (isResumed) setRefreshing(loading) { refresh ->
                 if (!refresh) {
                     menu?.let { UiTools.updateSortTitles(it, viewModel.provider) }
                     restoreMultiSelectHelper()



More information about the Android mailing list