[Android] Fix Padding erased on audio player display
Geoffrey Métais
git at videolan.org
Wed Jul 19 19:20:33 CEST 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Jul 19 17:49:16 2017 +0200| [13148c103ef72674eb0a161f52115b25591b8a7a] | committer: Geoffrey Métais
Fix Padding erased on audio player display
> https://code.videolan.org/videolan/vlc-android/commit/13148c103ef72674eb0a161f52115b25591b8a7a
---
.../vlc/gui/AudioPlayerContainerActivity.java | 22 ++++++++++++++++------
.../src/org/videolan/vlc/gui/InfoActivity.java | 2 +-
.../src/org/videolan/vlc/gui/PlaylistActivity.java | 2 +-
3 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java b/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java
index b9dd1d088..e12a45cce 100644
--- a/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java
@@ -89,6 +89,7 @@ public class AudioPlayerContainerActivity extends BaseActivity implements Playba
protected PlaybackService mService;
protected BottomSheetBehavior mBottomSheetBehavior;
protected View mFragmentContainer;
+ private int mOriginalBottomPadding;
private View mScanProgressLayout;
private TextView mScanProgressText;
private ProgressBar mScanProgressBar;
@@ -128,7 +129,9 @@ public class AudioPlayerContainerActivity extends BaseActivity implements Playba
@Override
protected void onPostCreate(@Nullable Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
- mFragmentContainer = findViewById(R.id.fragment_placeholder);
+ if (mFragmentContainer == null)
+ mFragmentContainer = findViewById(R.id.fragment_placeholder);
+ mOriginalBottomPadding = mFragmentContainer.getPaddingBottom();
}
@Override
@@ -163,7 +166,7 @@ public class AudioPlayerContainerActivity extends BaseActivity implements Playba
protected void onResume() {
super.onResume();
if (mBottomSheetBehavior != null && mBottomSheetBehavior.getState() == BottomSheetBehavior.STATE_COLLAPSED) {
- mFragmentContainer.setPadding(0, 0, 0, mBottomSheetBehavior.getPeekHeight());
+ updateContainerPadding(true);
applyMarginToProgressBar(mBottomSheetBehavior.getPeekHeight());
}
}
@@ -258,7 +261,7 @@ public class AudioPlayerContainerActivity extends BaseActivity implements Playba
initAudioPlayer();
if (mAudioPlayerContainer.getVisibility() == View.GONE) {
mAudioPlayerContainer.setVisibility(View.VISIBLE);
- mFragmentContainer.setPadding(0, 0, 0, mBottomSheetBehavior.getPeekHeight());
+ updateContainerPadding(true);
applyMarginToProgressBar(mBottomSheetBehavior.getPeekHeight());
}
if (mBottomSheetBehavior.getState() == BottomSheetBehavior.STATE_HIDDEN) {
@@ -321,13 +324,20 @@ public class AudioPlayerContainerActivity extends BaseActivity implements Playba
mScanProgressText = (TextView) findViewById(R.id.scan_progress_text);
mScanProgressBar = (ProgressBar) findViewById(R.id.scan_progress_bar);
if (mBottomSheetBehavior != null && mBottomSheetBehavior.getState() == BottomSheetBehavior.STATE_COLLAPSED) {
- mFragmentContainer.setPadding(0, 0, 0, mBottomSheetBehavior.getPeekHeight());
+ updateContainerPadding(true);
applyMarginToProgressBar(mBottomSheetBehavior.getPeekHeight());
}
} else if (mScanProgressLayout != null)
mScanProgressLayout.setVisibility(View.VISIBLE);
}
+ private void updateContainerPadding(boolean show) {
+ int factor = show ? 1 : 0;
+ mFragmentContainer.setPadding(mFragmentContainer.getPaddingLeft(),
+ mFragmentContainer.getPaddingTop(), mFragmentContainer.getPaddingRight(),
+ mOriginalBottomPadding+factor*mBottomSheetBehavior.getPeekHeight());
+ }
+
private void applyMarginToProgressBar(int marginValue) {
if (mScanProgressLayout != null && mScanProgressLayout.getVisibility() == View.VISIBLE) {
CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) mScanProgressLayout.getLayoutParams();
@@ -391,12 +401,12 @@ public class AudioPlayerContainerActivity extends BaseActivity implements Playba
switch (newState) {
case BottomSheetBehavior.STATE_COLLAPSED:
removeTipViewIfDisplayed();
- mFragmentContainer.setPadding(0, 0, 0, mBottomSheetBehavior.getPeekHeight());
+ updateContainerPadding(true);
applyMarginToProgressBar(mBottomSheetBehavior.getPeekHeight());
break;
case BottomSheetBehavior.STATE_HIDDEN:
removeTipViewIfDisplayed();
- mFragmentContainer.setPadding(0, 0, 0, 0);
+ updateContainerPadding(false);
applyMarginToProgressBar(0);
break;
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/InfoActivity.java b/vlc-android/src/org/videolan/vlc/gui/InfoActivity.java
index b906e3ee8..ff4faaea8 100644
--- a/vlc-android/src/org/videolan/vlc/gui/InfoActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/InfoActivity.java
@@ -150,8 +150,8 @@ public class InfoActivity extends AudioPlayerContainerActivity implements View.O
@Override
protected void onPostCreate(@Nullable Bundle savedInstanceState) {
- super.onPostCreate(savedInstanceState);
mFragmentContainer = mBinding.container;
+ super.onPostCreate(savedInstanceState);
}
@Override
diff --git a/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.java b/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.java
index 6573fff0c..23ded9d57 100644
--- a/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.java
@@ -137,8 +137,8 @@ public class PlaylistActivity extends AudioPlayerContainerActivity implements IE
@Override
protected void onPostCreate(@Nullable Bundle savedInstanceState) {
- super.onPostCreate(savedInstanceState);
mFragmentContainer = mBinding.songs;
+ super.onPostCreate(savedInstanceState);
}
@Override
More information about the Android
mailing list