[Android] Animate playlist/cover switch

Geoffrey Métais git at videolan.org
Wed Mar 15 17:42:50 CET 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Mar 15 16:21:32 2017 +0100| [7685e0f7ea6e8542c83a002dc7da3777f171edfe] | committer: Geoffrey Métais

Animate playlist/cover switch

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

 vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
index e2a9ea1..17deaab 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
@@ -36,8 +36,10 @@ import android.os.Message;
 import android.preference.PreferenceManager;
 import android.support.annotation.Nullable;
 import android.support.annotation.RequiresPermission;
+import android.support.constraint.ConstraintSet;
 import android.support.design.widget.BottomSheetBehavior;
 import android.support.design.widget.Snackbar;
+import android.support.transition.TransitionManager;
 import android.support.v4.app.FragmentActivity;
 import android.support.v4.app.FragmentManager;
 import android.support.v7.widget.LinearLayoutManager;
@@ -96,6 +98,8 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
     private boolean mHeaderTimeVisible;
     private int mPlayerState;
     private String mCurrentCoverArt;
+    private final ConstraintSet coverConstraintSet = new ConstraintSet();
+    private final ConstraintSet playlistConstraintSet = new ConstraintSet();
 
     // Tips
     private static final String PREF_PLAYLIST_TIPS_SHOWN = "playlist_tips_shown";
@@ -138,6 +142,10 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
         registerForContextMenu(mBinding.songsList);
         getActivity().setVolumeControlStream(AudioManager.STREAM_MUSIC);
         setUserVisibleHint(true);
+        playlistConstraintSet.clone(mBinding.contentLayout);
+        coverConstraintSet.clone(mBinding.contentLayout);
+        coverConstraintSet.setVisibility(R.id.songs_list, View.GONE);
+        coverConstraintSet.setVisibility(R.id.cover_media_switcher, View.VISIBLE);
     }
 
     public void onPopupMenu(View anchor, final int position) {
@@ -408,10 +416,11 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
 
     public void onPlaylistSwitchClick(View view) {
         boolean showCover = mBinding.songsList.getVisibility() == View.VISIBLE;
+        TransitionManager.beginDelayedTransition(mBinding.contentLayout);
+        ConstraintSet cs = showCover ? coverConstraintSet : playlistConstraintSet;
+        cs.applyTo(mBinding.contentLayout);
         mBinding.playlistSwitch.setImageResource(UiTools.getResourceFromAttribute(view.getContext(),
                 showCover ? R.attr.ic_playlist : R.attr.ic_playlist_on));
-        mBinding.songsList.setVisibility(showCover ? View.GONE : View.VISIBLE);
-        mBinding.coverMediaSwitcher.setVisibility(showCover ? View.VISIBLE : View.GONE);
     }
 
     public void onShuffleClick(View view) {



More information about the Android mailing list