[Android] Fix crash in PlaylistFragment on mobile

Nicolas Pomepuy git at videolan.org
Thu Jul 11 09:45:51 CEST 2019


vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Thu Jul 11 09:16:20 2019 +0200| [bdd3f470d9a08b489fb777fa2144a6fd9b41b98f] | committer: Nicolas Pomepuy

Fix crash in PlaylistFragment on mobile

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

 vlc-android/src/org/videolan/vlc/gui/PlaylistFragment.kt | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/PlaylistFragment.kt b/vlc-android/src/org/videolan/vlc/gui/PlaylistFragment.kt
index 74bae802a..c388ee468 100644
--- a/vlc-android/src/org/videolan/vlc/gui/PlaylistFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/PlaylistFragment.kt
@@ -84,7 +84,10 @@ class PlaylistFragment : BaseAudioBrowser<PlaylistsViewModel>(), SwipeRefreshLay
         //size of an item
         val spacing = resources.getDimension(R.dimen.kl_half).toInt()
 
-        val itemSize = RecyclerSectionItemGridDecoration.getItemSize(min(requireActivity().getScreenWidth(), resources.getDimension(R.dimen.default_content_width).toInt()) - spacing * 2, nbColumns, spacing)
+        val dimension = resources.getDimension(R.dimen.default_content_width)
+        val totalWidth = if (dimension > 0) min(requireActivity().getScreenWidth(), dimension.toInt()) else requireActivity().getScreenWidth()
+
+        val itemSize = RecyclerSectionItemGridDecoration.getItemSize(totalWidth - spacing * 2, nbColumns, spacing)
 
         playlistAdapter = AudioBrowserAdapter(MediaLibraryItem.TYPE_PLAYLIST, this, itemSize)
         adapter = playlistAdapter



More information about the Android mailing list