[Android] Close Albums/tracks once the artist/genre is empty

Geoffrey Métais git at videolan.org
Fri Sep 14 16:04:07 CEST 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Sep 14 16:02:57 2018 +0200| [83cc5c5719f39c494cf0ae2cc6d277bc22d3e455] | committer: Geoffrey Métais

Close Albums/tracks once the artist/genre is empty

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

 .../src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
index 0a4c35301..296798b50 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
@@ -20,6 +20,7 @@
 
 package org.videolan.vlc.gui.audio;
 
+import android.app.Activity;
 import android.arch.lifecycle.Observer;
 import android.arch.lifecycle.ViewModelProviders;
 import android.arch.paging.PagedList;
@@ -138,6 +139,7 @@ public class AudioAlbumsSongsFragment extends BaseAudioBrowser implements SwipeR
         return v;
     }
 
+    @SuppressWarnings("unchecked")
     @Override
     public void onViewCreated(View view, Bundle savedInstanceState) {
         super.onViewCreated(view, savedInstanceState);
@@ -160,7 +162,12 @@ public class AudioAlbumsSongsFragment extends BaseAudioBrowser implements SwipeR
         ((MLPagedModel)tracksModel).getPagedList().observe(this, new Observer<PagedList<MediaLibraryItem>>() {
             @Override
             public void onChanged(@Nullable PagedList<MediaLibraryItem> tracks) {
-                if (tracks != null) mSongsAdapter.submitList(tracks);
+                if (tracks != null) {
+                    if (tracks.isEmpty() && !tracksModel.isFiltering()) {
+                        final Activity activity = getActivity();
+                        if (activity != null) activity.finish();
+                    } else mSongsAdapter.submitList(tracks);
+                }
             }
         });
     }



More information about the Android mailing list