[Android] Disable cover switch animation before Android ICS

Geoffrey Métais git at videolan.org
Thu Mar 16 13:10:29 CET 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Mar 16 11:22:48 2017 +0100| [8fdaa8fcb0a1ba62c717856bfbcdf7edad968cfb] | committer: Geoffrey Métais

Disable cover switch animation before Android ICS

> https://code.videolan.org/videolan/vlc-android/commit/8fdaa8fcb0a1ba62c717856bfbcdf7edad968cfb
---

 .../org/videolan/vlc/gui/audio/AudioPlayer.java    | 29 ++++++++++++++--------
 1 file changed, 18 insertions(+), 11 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 17deaab..607721e 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
@@ -98,8 +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();
+    private final ConstraintSet coverConstraintSet = AndroidUtil.isICSOrLater() ? new ConstraintSet() : null;
+    private final ConstraintSet playlistConstraintSet = AndroidUtil.isICSOrLater() ? new ConstraintSet() : null;
 
     // Tips
     private static final String PREF_PLAYLIST_TIPS_SHOWN = "playlist_tips_shown";
@@ -142,10 +142,12 @@ 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);
+        if (playlistConstraintSet != null) {
+            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) {
@@ -416,11 +418,16 @@ 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));
+        if (playlistConstraintSet != null) {
+            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));
+        } else {
+            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