Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setBottomSheetCallback is deprecated

Tags:

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

like image 389
Fatima MarFr Avatar asked Dec 15 '19 11:12

Fatima MarFr


People also ask

How do I stop my android from dragging the bottom sheet?

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.

What is BottomSheetBehavior Android?

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 .

How can I dim the background when BottomSheet is displayed without using dialog?

Using the Interface - onSlide which as a parameter slideOffSet of type float , can be used to dim the background.


1 Answers

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

like image 74
Bob Avatar answered Oct 12 '22 04:10

Bob