[Android] Fix crashes and cover issues in the artists grid

Nicolas Pomepuy git at videolan.org
Mon Jun 17 17:04:23 CEST 2019


vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Mon Jun 17 14:31:46 2019 +0200| [916d7d7ad73a4357f642d9c47e6c14256582319f] | committer: Nicolas Pomepuy

Fix crashes and cover issues in the artists grid

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

 vlc-android/src/org/videolan/vlc/gui/PlaylistFragment.kt            | 4 ++--
 .../src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.kt      | 6 +++---
 vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.kt   | 2 +-
 vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt         | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/PlaylistFragment.kt b/vlc-android/src/org/videolan/vlc/gui/PlaylistFragment.kt
index bdfbde46e..909e39dd9 100644
--- a/vlc-android/src/org/videolan/vlc/gui/PlaylistFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/PlaylistFragment.kt
@@ -74,7 +74,7 @@ class PlaylistFragment : BaseAudioBrowser<PlaylistsViewModel>(), SwipeRefreshLay
 
     override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
         binding = PlaylistsFragmentBinding.inflate(inflater, container, false)
-        playlists = binding.swipeLayout.findViewById(R.id.playlist_list)
+        playlists = binding.swipeLayout.findViewById(R.id.audio_list)
         return binding.root
     }
 
@@ -86,7 +86,7 @@ class PlaylistFragment : BaseAudioBrowser<PlaylistsViewModel>(), SwipeRefreshLay
         gridLayoutManager.spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
             override fun getSpanSize(position: Int): Int {
 
-                if (position == playlistAdapter.getItemCount() - 1) {
+                if (position == playlistAdapter.itemCount - 1) {
                     return 1
                 }
                 if (viewModel.provider.isFirstInSection(position + 1)) {
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.kt b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.kt
index 7a8a7dbdf..bd7bc6e10 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.kt
@@ -98,8 +98,8 @@ class AudioAlbumsSongsFragment : BaseAudioBrowser<AlbumSongsViewModel>(), SwipeR
     override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
         super.onViewCreated(view, savedInstanceState)
 
-        val albumsList = viewPager!!.getChildAt(MODE_ALBUM) as RecyclerView
-        val songsList = viewPager!!.getChildAt(MODE_SONG) as RecyclerView
+        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
 
         lists = arrayOf(albumsList, songsList)
         val titles = arrayOf(getString(R.string.albums), getString(R.string.songs))
@@ -114,7 +114,7 @@ class AudioAlbumsSongsFragment : BaseAudioBrowser<AlbumSongsViewModel>(), SwipeR
         albumsList.adapter = albumsAdapter
         viewPager!!.offscreenPageLimit = MODE_TOTAL - 1
         @Suppress("UNCHECKED_CAST")
-        viewPager!!.adapter = AudioPagerAdapter(lists as Array<View>, titles)
+        viewPager!!.adapter = AudioPagerAdapter(arrayOf(viewPager!!.getChildAt(MODE_ALBUM), viewPager!!.getChildAt(MODE_SONG)), titles)
 
         fastScroller = view.rootView.findViewById<View>(R.id.songs_fast_scroller) as FastScroller
         fastScroller.attachToCoordinator(view.rootView.findViewById<View>(R.id.appbar) as AppBarLayout, view.rootView.findViewById<View>(R.id.coordinator) as CoordinatorLayout, view.rootView.findViewById<View>(R.id.fab) as FloatingActionButton)
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.kt b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.kt
index 7a50ccc71..1b6ce2bac 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.kt
@@ -65,7 +65,7 @@ class AudioBrowserAdapter @JvmOverloads constructor(private val type: Int, priva
     var itemSize = -1
     val multiSelectHelper: MultiSelectHelper<MediaLibraryItem> = MultiSelectHelper(this, UPDATE_SELECTION)
     private val mDefaultCover: BitmapDrawable?
-    var focusNext = -1
+    private var focusNext = -1
     private var focusListener: FocusableRecyclerView.FocusListener? = null
 
     val isEmpty: Boolean
diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt b/vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt
index 0ac13066e..58b23cf79 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/ImageLoader.kt
@@ -72,7 +72,7 @@ fun loadPlaylistImageWithWidth(v: ImageView, item: MediaLibraryItem?, imageWidth
     if (imageWidth == 0) return
     if (item == null) return
     val binding = DataBindingUtil.findBinding<ViewDataBinding>(v)
-    AppScope.launch { getPlaylistImage(v, item, binding, imageWidth.toInt()) }
+    AppScope.launch { if (item.itemType == MediaLibraryItem.TYPE_PLAYLIST) getPlaylistImage(v, item, binding, imageWidth) else loadImage(v, item) }
 }
 
 fun getAudioIconDrawable(context: Context?, type: Int): BitmapDrawable? = context?.let {



More information about the Android mailing list