ui: fix bottom sheet initialization
Fix an issue on some devices where bottom sheet transitions would not initialize correctly. Turns out I can't try to do transitions using the callback and simply initalizing them on startup. Apparently on some devices, CoordinatorLayout will simply not lay out until some arbitrary point past onResume. This breaks our transitions. Fix it by using a pre-draw listener instead. I cannot believe I have to do this.
This commit is contained in:
@@ -506,6 +506,8 @@ public class NeoBottomSheetBehavior<V extends View> 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<V extends View> 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<V extends View> extends CoordinatorLayout.Be
|
||||
return calculateSlideOffset(bottomSheet.getTop());
|
||||
}
|
||||
|
||||
Log.d("NeoBottomSheetBehavior", "No bottom sheet");
|
||||
|
||||
return Float.MIN_VALUE;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user