Commit 15276398 authored by Geoffrey Métais's avatar Geoffrey Métais

Animate playlist/cover switch

parent 6b7499dc
......@@ -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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment