[Android] Audio browser: display a message when there is no media

Adrien Maglo git at videolan.org
Tue Feb 25 09:01:33 CET 2014


vlc-ports/android | branch: master | Adrien Maglo <magsoft at videolan.org> | Tue Feb 25 09:00:46 2014 +0100| [23d4da289301c929aecc7c85856755648a2c5017] | committer: Adrien Maglo

Audio browser: display a message when there is no media

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=23d4da289301c929aecc7c85856755648a2c5017
---

 vlc-android/res/layout/audio_browser.xml                     |   10 ++++++++++
 .../src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java |   10 ++++++++++
 2 files changed, 20 insertions(+)

diff --git a/vlc-android/res/layout/audio_browser.xml b/vlc-android/res/layout/audio_browser.xml
index 288e64b..28b30a5 100644
--- a/vlc-android/res/layout/audio_browser.xml
+++ b/vlc-android/res/layout/audio_browser.xml
@@ -74,6 +74,16 @@
 	        android:layout_alignTop="@+id/header"
 	        android:background="@drawable/header_fadeout_overlay" />
     </RelativeLayout>
+
+    <TextView
+        android:id="@+id/no_media"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:gravity="center"
+        android:text="@string/nomedia"
+        android:textSize="20sp"
+        android:visibility="gone" />
+
     <org.videolan.vlc.widget.FlingViewGroup
         android:id="@+id/content"
         android:layout_width="fill_parent"
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
index 5a6c7e6..649aade 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
@@ -80,6 +80,8 @@ public class AudioBrowserFragment extends SherlockFragment {
     private AudioBrowserListAdapter mAlbumsAdapter;
     private AudioBrowserListAdapter mGenresAdapter;
 
+    private View mEmptyView;
+
     public final static int MODE_TOTAL = 4; // Number of audio browser modes
     public final static int MODE_ARTIST = 0;
     public final static int MODE_ALBUM = 1;
@@ -127,6 +129,8 @@ public class AudioBrowserFragment extends SherlockFragment {
             }
         });
 
+        mEmptyView = v.findViewById(R.id.no_media);
+
         ListView songsList = (ListView)v.findViewById(R.id.songs_list);
         ListView artistList = (ListView)v.findViewById(R.id.artists_list);
         ListView albumList = (ListView)v.findViewById(R.id.albums_list);
@@ -360,6 +364,12 @@ public class AudioBrowserFragment extends SherlockFragment {
 
     private void updateLists() {
         List<Media> audioList = MediaLibrary.getInstance(getActivity()).getAudioItems();
+
+        if (audioList.isEmpty())
+            mEmptyView.setVisibility(View.VISIBLE);
+        else
+            mEmptyView.setVisibility(View.GONE);
+
         mSongsAdapter.clear();
         mArtistsAdapter.clear();
         mAlbumsAdapter.clear();



More information about the Android mailing list