[Android] Fix sizing issue with audio card/list on tablets

Nicolas Pomepuy git at videolan.org
Fri Apr 24 11:07:55 CEST 2020


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Thu Apr 23 09:11:34 2020 +0200| [b2758c067669be0b3475b4d6f77cf6852f7bf7f5] | committer: Geoffrey Métais

Fix sizing issue with audio card/list on tablets

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

 application/vlc-android/res/layout/audio_albums_songs.xml         | 2 +-
 .../src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.kt    | 6 ++++--
 .../src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt        | 8 +++-----
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/application/vlc-android/res/layout/audio_albums_songs.xml b/application/vlc-android/res/layout/audio_albums_songs.xml
index 90591aac2..884da37b9 100644
--- a/application/vlc-android/res/layout/audio_albums_songs.xml
+++ b/application/vlc-android/res/layout/audio_albums_songs.xml
@@ -17,7 +17,7 @@
 
     <org.videolan.vlc.gui.view.SwipeRefreshLayout
             android:id="@+id/swipeLayout"
-            android:layout_width="@dimen/default_content_width"
+            android:layout_width="match_parent"
             android:layout_height="match_parent"
             android:layout_below="@+id/searchButton"
             android:layout_centerHorizontal="true">
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.kt
index 7eb6d56d2..bf68cb126 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.kt
@@ -98,8 +98,7 @@ class AudioAlbumsSongsFragment : BaseAudioBrowser<AlbumSongsViewModel>(), SwipeR
         super.onViewCreated(view, savedInstanceState)
 
         spacing = resources.getDimension(R.dimen.kl_small).toInt()
-        val itemSize = if (viewModel.providersInCard[0]) RecyclerSectionItemGridDecoration.getItemSize(requireActivity().getScreenWidth(), nbColumns, spacing)
-        else -1
+        val itemSize = RecyclerSectionItemGridDecoration.getItemSize(requireActivity().getScreenWidth(), nbColumns, spacing)
 
         val albumsList = viewPager.getChildAt(MODE_ALBUM).findViewById(R.id.audio_list) as RecyclerView
         val songsList = viewPager.getChildAt(MODE_SONG).findViewById(R.id.audio_list) as RecyclerView
@@ -165,6 +164,9 @@ class AudioAlbumsSongsFragment : BaseAudioBrowser<AlbumSongsViewModel>(), SwipeR
                 lists[index].layoutManager = LinearLayoutManager(activity)
             }
         }
+        val lp = lists[index].layoutParams
+        lp.width = if (viewModel.providersInCard[index]) ViewGroup.LayoutParams.MATCH_PARENT else requireActivity().resources.getDimension(R.dimen.default_content_width).toInt()
+        lists[index].layoutParams = lp
     }
 
     override fun sortBy(sort: Int) {
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt
index 60ff5fba2..d8d16fdd0 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt
@@ -136,11 +136,6 @@ class AudioBrowserFragment : BaseAudioBrowser<AudioBrowserViewModel>() {
             val list = lists[i]
             list.adapter = adapters[i]
             list.addOnScrollListener(scrollListener)
-            if (viewModel.providersInCard[i]) {
-                val lp = list.layoutParams
-                lp.width = ViewGroup.LayoutParams.MATCH_PARENT
-                list.layoutParams = lp
-            }
         }
         viewPager.setOnTouchListener(swipeFilter)
         swipeRefreshLayout.setOnRefreshListener {
@@ -187,6 +182,9 @@ class AudioBrowserFragment : BaseAudioBrowser<AudioBrowserViewModel>() {
                 lists[index].layoutManager = LinearLayoutManager(activity)
             }
         }
+        val lp = lists[index].layoutParams
+        lp.width = if (viewModel.providersInCard[index]) ViewGroup.LayoutParams.MATCH_PARENT else requireActivity().resources.getDimension(R.dimen.default_content_width).toInt()
+        lists[index].layoutParams = lp
     }
 
     override fun onSaveInstanceState(outState: Bundle) {



More information about the Android mailing list