Fixed NPEs related to bottom sheet
This commit is contained in:
parent
342ad86467
commit
fc54186373
|
@ -166,6 +166,9 @@ public class MainActivity extends CastEnabledActivity {
|
|||
public void onSlide(@NonNull View view, float slideOffset) {
|
||||
AudioPlayerFragment audioPlayer = (AudioPlayerFragment) getSupportFragmentManager()
|
||||
.findFragmentByTag(AudioPlayerFragment.TAG);
|
||||
if (audioPlayer == null) {
|
||||
return;
|
||||
}
|
||||
float condensedSlideOffset = Math.max(0.0f, Math.min(0.2f, slideOffset - 0.2f)) / 0.2f;
|
||||
audioPlayer.getExternalPlayerHolder().setAlpha(1 - condensedSlideOffset);
|
||||
audioPlayer.getExternalPlayerHolder().setVisibility(
|
||||
|
|
|
@ -135,7 +135,12 @@ public class AudioPlayerFragment extends Fragment implements
|
|||
pager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
pager.post(() -> ((MainActivity) getActivity()).getBottomSheet().updateScrollingChild());
|
||||
pager.post(() -> {
|
||||
if (getActivity() != null) {
|
||||
// By the time this is posted, the activity might be closed again.
|
||||
((MainActivity) getActivity()).getBottomSheet().updateScrollingChild();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
pageIndicator = root.findViewById(R.id.page_indicator);
|
||||
|
|
Loading…
Reference in New Issue