Use nicer animation when sliding up player (#6301)
This commit is contained in:
parent
7af00f7e83
commit
db5d47967a
@ -209,10 +209,7 @@ public class MainActivity extends CastEnabledActivity {
|
||||
audioPlayer.scrollToPage(AudioPlayerFragment.POS_COVER);
|
||||
}
|
||||
|
||||
float condensedSlideOffset = Math.max(0.0f, Math.min(0.2f, slideOffset - 0.2f)) / 0.2f;
|
||||
audioPlayer.getExternalPlayerHolder().setAlpha(1 - condensedSlideOffset);
|
||||
audioPlayer.getExternalPlayerHolder().setVisibility(
|
||||
condensedSlideOffset > 0.99f ? View.GONE : View.VISIBLE);
|
||||
audioPlayer.fadePlayerToToolbar(slideOffset);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -183,10 +183,6 @@ public class AudioPlayerFragment extends Fragment implements
|
||||
sbPosition.setDividerPos(dividerPos);
|
||||
}
|
||||
|
||||
public View getExternalPlayerHolder() {
|
||||
return getView().findViewById(R.id.playerFragment);
|
||||
}
|
||||
|
||||
private void setupControlButtons() {
|
||||
butRev.setOnClickListener(v -> {
|
||||
if (controller != null) {
|
||||
@ -528,6 +524,16 @@ public class AudioPlayerFragment extends Fragment implements
|
||||
return false;
|
||||
}
|
||||
|
||||
public void fadePlayerToToolbar(float slideOffset) {
|
||||
float playerFadeProgress = Math.max(0.0f, Math.min(0.2f, slideOffset - 0.2f)) / 0.2f;
|
||||
View player = getView().findViewById(R.id.playerFragment);
|
||||
player.setAlpha(1 - playerFadeProgress);
|
||||
player.setVisibility(playerFadeProgress > 0.99f ? View.GONE : View.VISIBLE);
|
||||
float toolbarFadeProgress = Math.max(0.0f, Math.min(0.2f, slideOffset - 0.6f)) / 0.2f;
|
||||
toolbar.setAlpha(toolbarFadeProgress);
|
||||
toolbar.setVisibility(toolbarFadeProgress < 0.01f ? View.INVISIBLE : View.VISIBLE);
|
||||
}
|
||||
|
||||
private static class AudioPlayerPagerAdapter extends FragmentStateAdapter {
|
||||
private static final String TAG = "AudioPlayerPagerAdapter";
|
||||
|
||||
|
@ -13,7 +13,6 @@
|
||||
android:layout_gravity="top"
|
||||
android:elevation="8dp"
|
||||
android:outlineProvider="none"
|
||||
android:paddingBottom="1dp"
|
||||
tools:layout_height="@dimen/external_player_height" />
|
||||
|
||||
<RelativeLayout
|
||||
|
Loading…
x
Reference in New Issue
Block a user