gpt4 book ai didi

android - setBottomSheetCallback 已弃用

转载 作者:行者123 更新时间:2023-11-29 18:25:21 25 4
gpt4 key购买 nike

在使用 ml kit firebise 开发用于物体检测的应用程序时,我已经实现了我的底部工作表,但它不起作用,所以相机仍然聚焦在物体上而没有任何结果。代码:

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);
}
}
});

错误:setBottomSheetCallback 已弃用

任何帮助将不胜感激

最佳答案

改用 addBottomSheetCallbackremoveBottomSheetCallback

查看 Android docs .

来自文档:

setBottomSheetCallback

This method is deprecated. useaddBottomSheetCallback(BottomSheetCallback) andremoveBottomSheetCallback(BottomSheetCallback) instead

关于android - setBottomSheetCallback 已弃用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59343490/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com