while developing an app for object detection using ml kit firebise, i've implemented my bottom sheet but it's not working,so the camera still focused on the object without any result. code:
private void setUpBottomSheet() { bottomSheetBehavior = BottomSheetBehavior.from(findViewById(R.id.bottom_sheet)); bottomSheetBehavior.setBottomSheetCallback( new BottomSheetBehavior.BottomSheetCallback() { @Override public void onStateChanged(@NonNull View bottomSheet, int newState) { Log.d(TAG, "Bottom sheet new state: " + newState); bottomSheetScrimView.setVisibility( newState == BottomSheetBehavior.STATE_HIDDEN ? View.GONE : View.VISIBLE); graphicOverlay.clear(); switch (newState) { case BottomSheetBehavior.STATE_HIDDEN: workflowModel.setWorkflowState(WorkflowState.DETECTING); break; case BottomSheetBehavior.STATE_COLLAPSED: case BottomSheetBehavior.STATE_EXPANDED: case BottomSheetBehavior.STATE_HALF_EXPANDED: slidingSheetUpFromHiddenState = false; break; case BottomSheetBehavior.STATE_DRAGGING: case BottomSheetBehavior.STATE_SETTLING: default: break; } } @Override public void onSlide(@NonNull View bottomSheet, float slideOffset) { SearchedObject searchedObject = workflowModel.searchedObject.getValue(); if (searchedObject == null || Float.isNaN(slideOffset)) { return; } int collapsedStateHeight = Math.min(bottomSheetBehavior.getPeekHeight(), bottomSheet.getHeight()); if (slidingSheetUpFromHiddenState) { RectF thumbnailSrcRect = graphicOverlay.translateRect(searchedObject.getBoundingBox()); bottomSheetScrimView.updateWithThumbnailTranslateAndScale( objectThumbnailForBottomSheet, collapsedStateHeight, slideOffset, thumbnailSrcRect); } else { bottomSheetScrimView.updateWithThumbnailTranslate( objectThumbnailForBottomSheet, collapsedStateHeight, slideOffset, bottomSheet); } } });
Error: setBottomSheetCallback is deprecated
any help would be appreciated
Disable drag of BottomSheetDialogFragment Even if we have made the BottomSheetDialogFragment as expanded, user can hold the top part of the BottomSheet and drag to show peek view. It can also be disabled by overriding onStateChanged() . This will set the expanded state even if user drags the view.
Bottom Sheet can be either modal — that slides up from the bottom of the screen to reveal more content or persistent — when they're integrated with the app to display supporting content. We will talk about the persistent ones. It also knows as BottomSheetBehavior .
Using the Interface - onSlide which as a parameter slideOffSet of type float , can be used to dim the background.
Use addBottomSheetCallback
and removeBottomSheetCallback
instead.
Check out the Android docs.
From the docs:
setBottomSheetCallback
This method is deprecated. use addBottomSheetCallback(BottomSheetCallback) and removeBottomSheetCallback(BottomSheetCallback) instead
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With