[Android] Improve FAB behavior in audio

Geoffrey Métais git at videolan.org
Fri Nov 3 17:21:51 CET 2017


vlc-android | branch: 2.5.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Nov  3 17:21:14 2017 +0100| [7bfa71c5fb9169c414a0994c42d2c8808640dece] | committer: Geoffrey Métais

Improve FAB behavior in audio

Close #402

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

 .../videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java  | 15 ++++++++++++++-
 .../org/videolan/vlc/gui/audio/AudioBrowserFragment.java  |  5 +++++
 .../videolan/vlc/gui/browser/MediaBrowserFragment.java    |  3 +--
 3 files changed, 20 insertions(+), 3 deletions(-)

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 d35d90ff7..0460d4cca 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
@@ -60,6 +60,7 @@ import org.videolan.vlc.util.FileUtils;
 import org.videolan.vlc.util.Util;
 
 import java.util.ArrayList;
+import java.util.List;
 
 public class AudioAlbumsSongsFragment extends BaseAudioBrowser implements SwipeRefreshLayout.OnRefreshListener, TabLayout.OnTabSelectedListener {
 
@@ -155,7 +156,7 @@ public class AudioAlbumsSongsFragment extends BaseAudioBrowser implements SwipeR
             rv.setLayoutManager(llm);
             rv.setRecycledViewPool(rvp);
         }
-
+        mFabPlay.setImageResource(R.drawable.ic_fab_play);
         mTabLayout.addOnTabSelectedListener(this);
         updateList();
     }
@@ -377,4 +378,16 @@ public class AudioAlbumsSongsFragment extends BaseAudioBrowser implements SwipeR
         return mViewPager.getCurrentItem() == MODE_SONG;
     }
 
+    @Override
+    public void setFabPlayVisibility(boolean enable) {
+        super.setFabPlayVisibility(enable && mViewPager.getCurrentItem() == 1);
+    }
+
+    @Override
+    public void onFabPlayClick(View view) {
+        if (mService == null) return;
+        @SuppressWarnings("unchecked")
+        final List<MediaWrapper> list = (List<MediaWrapper>)(List<?>) mSongsAdapter.getMediaItems();
+        mService.load(list, 0);
+    }
 }
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 02e7e0a01..57cbda128 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
@@ -343,6 +343,11 @@ public class AudioBrowserFragment extends BaseAudioBrowser implements SwipeRefre
         }
     }
 
+    @Override
+    public void setFabPlayVisibility(boolean enable) {
+        super.setFabPlayVisibility(enable && mViewPager.getCurrentItem() == MODE_SONG);
+    }
+
     public void setFabPlayShuffleAllVisibility() {
         setFabPlayVisibility(mViewPager.getCurrentItem() == MODE_SONG);
     }
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.java
index e19ff102b..518bec401 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.java
@@ -77,13 +77,12 @@ public abstract class MediaBrowserFragment extends PlaybackServiceFragment imple
         super.onViewCreated(view, savedInstanceState);
         if (mSwipeRefreshLayout != null)
             mSwipeRefreshLayout.setColorSchemeResources(R.color.orange700);
+            mFabPlay = getActivity().findViewById(R.id.fab);
     }
 
 
     public void onStart() {
         super.onStart();
-        if (mFabPlay == null)
-            mFabPlay = getActivity().findViewById(R.id.fab);
         if (!isHidden())
             onHiddenChanged(false);
     }



More information about the Android mailing list