diff --git a/app/src/main/java/com/google/android/material/bottomsheet/NeoBottomSheetBehavior.java b/app/src/main/java/com/google/android/material/bottomsheet/NeoBottomSheetBehavior.java index 9d5fdffd6..7882d1798 100644 --- a/app/src/main/java/com/google/android/material/bottomsheet/NeoBottomSheetBehavior.java +++ b/app/src/main/java/com/google/android/material/bottomsheet/NeoBottomSheetBehavior.java @@ -506,6 +506,8 @@ public class NeoBottomSheetBehavior extends CoordinatorLayout.Be } if (viewRef == null) { + + Log.d("NeoBottomSheetBehavior", "Lay out time"); // First layout with this behavior. peekHeightMin = parent.getResources().getDimensionPixelSize(R.dimen.design_bottom_sheet_peek_height_min); @@ -1076,6 +1078,7 @@ public class NeoBottomSheetBehavior extends CoordinatorLayout.Be */ public float calculateSlideOffset() { if (viewRef == null) { + Log.d("NeoBottomSheetBehavior", "No view ref"); return Float.MIN_VALUE; } @@ -1084,6 +1087,8 @@ public class NeoBottomSheetBehavior extends CoordinatorLayout.Be return calculateSlideOffset(bottomSheet.getTop()); } + Log.d("NeoBottomSheetBehavior", "No bottom sheet"); + return Float.MIN_VALUE; } diff --git a/app/src/main/java/org/oxycblt/auxio/MainFragment.kt b/app/src/main/java/org/oxycblt/auxio/MainFragment.kt index deb75c451..d4556d864 100644 --- a/app/src/main/java/org/oxycblt/auxio/MainFragment.kt +++ b/app/src/main/java/org/oxycblt/auxio/MainFragment.kt @@ -75,23 +75,11 @@ class MainFragment : ViewBindingFragment() { val playbackSheetBehavior = binding.playbackSheet.coordinatorLayoutBehavior as PlaybackSheetBehavior - - playbackSheetBehavior.addBottomSheetCallback( - object : NeoBottomSheetBehavior.BottomSheetCallback() { - override fun onSlide(bottomSheet: View, slideOffset: Float) { - handleSheetTransitions() - } - - override fun onStateChanged(bottomSheet: View, newState: Int) {} - }) - val queueSheetBehavior = binding.queueSheet.coordinatorLayoutBehavior as QueueSheetBehavior queueSheetBehavior.addBottomSheetCallback( object : NeoBottomSheetBehavior.BottomSheetCallback() { - override fun onSlide(bottomSheet: View, slideOffset: Float) { - handleSheetTransitions() - } + override fun onSlide(bottomSheet: View, slideOffset: Float) {} override fun onStateChanged(bottomSheet: View, newState: Int) { playbackSheetBehavior.isDraggable = @@ -100,11 +88,13 @@ class MainFragment : ViewBindingFragment() { } }) - binding.root.post { + // We would use the onSlide callback, but doing that would require us to initialize + // when the view first starts up, and that may not always work due to the insanity of + // the CoordinatorLayout lifecycle. Instead, do the less efficient alternative of updating + // the transition on every redraw. + binding.playbackSheet.viewTreeObserver.addOnPreDrawListener { handleSheetTransitions() - playbackSheetBehavior.isDraggable = - !playbackSheetBehavior.isHideable && - queueSheetBehavior.state == BottomSheetBehavior.STATE_COLLAPSED + true } // --- VIEWMODEL SETUP --- @@ -164,8 +154,7 @@ class MainFragment : ViewBindingFragment() { private fun handleMainNavigation(action: MainNavigationAction?) { if (action == null) return - - val binding = requireBinding() + when (action) { is MainNavigationAction.Expand -> tryExpandAll() is MainNavigationAction.Collapse -> tryCollapseAll()