[Android] Fix audio player header display on device rotation

Geoffrey Métais git at videolan.org
Tue Aug 1 18:33:28 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Aug  1 18:32:42 2017 +0200| [e92fc330fd17c72771c7be0da345034802e6d303] | committer: Geoffrey Métais

Fix audio player header display on device rotation

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

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

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 82e2378cf..6c16f0eb3 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
@@ -111,6 +111,8 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
     @Override
     public void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
+        if (savedInstanceState != null)
+            mPlayerState = savedInstanceState.getInt("player_state");
         mSettings = PreferenceManager.getDefaultSharedPreferences(getActivity());
     }
 
@@ -164,6 +166,12 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
         super.onStart();
     }
 
+    @Override
+    public void onSaveInstanceState(Bundle outState) {
+        super.onSaveInstanceState(outState);
+        outState.putInt("player_state", mPlayerState);
+    }
+
     public void onPopupMenu(View anchor, final int position) {
         final Activity activity = getActivity();
         if (activity == null || position >= mPlaylistAdapter.getItemCount())
@@ -322,6 +330,8 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
                                     mBinding.backgroundView.setImageBitmap(blurredCover);
                                     mBinding.backgroundView.setVisibility(View.VISIBLE);
                                     mBinding.songsList.setBackgroundResource(0);
+                                    if (mPlayerState == BottomSheetBehavior.STATE_EXPANDED)
+                                        mBinding.header.setBackgroundResource(0);
                                 }
                             });
                         else {
@@ -344,6 +354,7 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
     @MainThread
     private void setDefaultBackground() {
         mBinding.songsList.setBackgroundResource(DEFAULT_BACKGROUND_ID);
+        mBinding.header.setBackgroundResource(DEFAULT_BACKGROUND_ID);
         mBinding.backgroundView.setVisibility(View.INVISIBLE);
     }
 



More information about the Android mailing list