[Android] Fix bottom activities padding with audio player
Geoffrey Métais
git at videolan.org
Wed Jan 16 15:22:10 CET 2019
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Jan 16 15:11:59 2019 +0100| [3e279e6c74344ac46e482c2c45c2440364bb3476] | committer: Geoffrey Métais
Fix bottom activities padding with audio player
> https://code.videolan.org/videolan/vlc-android/commit/3e279e6c74344ac46e482c2c45c2440364bb3476
---
.../vlc/gui/AudioPlayerContainerActivity.java | 34 ++++++----------------
1 file changed, 9 insertions(+), 25 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java b/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java
index d26a8f81a..9f62491be 100644
--- a/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java
@@ -141,7 +141,6 @@ public class AudioPlayerContainerActivity extends BaseActivity {
protected void onStart() {
ExternalMonitor.INSTANCE.subscribeStorageCb(this);
super.onStart();
- if (PlaylistManager.Companion.getShowAudioPlayer().getValue()) showAudioPlayer();
}
@Override
@@ -150,15 +149,6 @@ public class AudioPlayerContainerActivity extends BaseActivity {
mPreventRescan = true;
}
- @Override
- protected void onResume() {
- super.onResume();
- if (mBottomSheetBehavior != null && mBottomSheetBehavior.getState() == BottomSheetBehavior.STATE_COLLAPSED) {
- updateContainerPadding(true);
- applyMarginToProgressBar(mBottomSheetBehavior.getPeekHeight());
- }
- }
-
@Override
protected void onStop() {
super.onStop();
@@ -201,10 +191,9 @@ public class AudioPlayerContainerActivity extends BaseActivity {
mPreventRescan = false;
return;
}
- FragmentManager fm = getSupportFragmentManager();
- Fragment current = fm.findFragmentById(R.id.fragment_placeholder);
- if (current != null && current instanceof IRefreshable)
- ((IRefreshable) current).refresh();
+ final FragmentManager fm = getSupportFragmentManager();
+ final Fragment current = fm.findFragmentById(R.id.fragment_placeholder);
+ if (current instanceof IRefreshable) ((IRefreshable) current).refresh();
}
/**
@@ -250,8 +239,6 @@ public class AudioPlayerContainerActivity extends BaseActivity {
if (!isAudioPlayerReady()) initAudioPlayer();
if (mAudioPlayerContainer.getVisibility() == View.GONE) {
mAudioPlayerContainer.setVisibility(View.VISIBLE);
- updateContainerPadding(true);
- applyMarginToProgressBar(mBottomSheetBehavior.getPeekHeight());
}
if (mBottomSheetBehavior.getState() == BottomSheetBehavior.STATE_HIDDEN) {
mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
@@ -306,10 +293,6 @@ public class AudioPlayerContainerActivity extends BaseActivity {
mScanProgressLayout = findViewById(R.id.scan_progress_layout);
mScanProgressText = findViewById(R.id.scan_progress_text);
mScanProgressBar = findViewById(R.id.scan_progress_bar);
- if (mBottomSheetBehavior != null && mBottomSheetBehavior.getState() == BottomSheetBehavior.STATE_COLLAPSED) {
- updateContainerPadding(true);
- applyMarginToProgressBar(mBottomSheetBehavior.getPeekHeight());
- }
} else if (mScanProgressLayout != null)
mScanProgressLayout.setVisibility(View.VISIBLE);
final ScanProgress sp = MediaParsingService.Companion.getProgress().getValue();
@@ -322,9 +305,10 @@ public class AudioPlayerContainerActivity extends BaseActivity {
protected void updateContainerPadding(boolean show) {
if (mFragmentContainer == null) return;
int factor = show ? 1 : 0;
+ final int peekHeight = show && mBottomSheetBehavior != null ? mBottomSheetBehavior.getPeekHeight() : 0;
mFragmentContainer.setPadding(mFragmentContainer.getPaddingLeft(),
mFragmentContainer.getPaddingTop(), mFragmentContainer.getPaddingRight(),
- mOriginalBottomPadding+factor*mBottomSheetBehavior.getPeekHeight());
+ mOriginalBottomPadding+factor*peekHeight);
}
private void applyMarginToProgressBar(int marginValue) {
@@ -358,13 +342,9 @@ public class AudioPlayerContainerActivity extends BaseActivity {
switch (newState) {
case BottomSheetBehavior.STATE_COLLAPSED:
removeTipViewIfDisplayed();
- updateContainerPadding(true);
- applyMarginToProgressBar(mBottomSheetBehavior.getPeekHeight());
break;
case BottomSheetBehavior.STATE_HIDDEN:
removeTipViewIfDisplayed();
- updateContainerPadding(false);
- applyMarginToProgressBar(0);
break;
}
}
@@ -430,10 +410,14 @@ public class AudioPlayerContainerActivity extends BaseActivity {
break;
case ACTION_SHOW_PLAYER:
owner.showAudioPlayer();
+ owner.updateContainerPadding(true);
+ owner.applyMarginToProgressBar(owner.mBottomSheetBehavior.getPeekHeight());
break;
case ACTION_HIDE_PLAYER:
removeMessages(ACTION_SHOW_PLAYER);
owner.hideAudioPlayer();
+ owner.updateContainerPadding(false);
+ owner.applyMarginToProgressBar(0);
break;
}
}
More information about the Android
mailing list