Java Code Examples for android.support.design.widget.BottomSheetBehavior#STATE_HIDDEN

The following examples show how to use android.support.design.widget.BottomSheetBehavior#STATE_HIDDEN . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BottomSheetMenuDialog.java    From BottomSheetBuilder with Apache License 2.0 6 votes vote down vote up
@Override
public void onStateChanged(@NonNull View bottomSheet,
                           @BottomSheetBehavior.State int newState) {

    if (mCallback != null) {
        mCallback.onStateChanged(bottomSheet, newState);
    }

    //noinspection WrongConstant
    if (newState == BottomSheetBehavior.STATE_HIDDEN) {
        mBehavior.setBottomSheetCallback(null);
        try {
            BottomSheetMenuDialog.super.dismiss();
        } catch (IllegalArgumentException e) {
            // Ignore exception handling
        }

        // User dragged the sheet.
        if (!mClicked && !mRequestDismiss && !mRequestCancel && mOnCancelListener != null) {
            mOnCancelListener.onCancel(BottomSheetMenuDialog.this);
        }
    }
}
 
Example 2
Source File: ScrollingActivity.java    From Android-Multi-Theme-UI with Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(View view) {
    switch (view.getId()){
        case R.id.theme_selected :
        case R.id.fab:
            // change the state of the bottom sheet
            switch (mBottomSheetBehavior.getState()){
                case BottomSheetBehavior.STATE_HIDDEN :
                    mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
                    break;

                case BottomSheetBehavior.STATE_COLLAPSED :
                    mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
                    break;

                case BottomSheetBehavior.STATE_EXPANDED :
                    mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
                    break;
            }
            break;
    }
}
 
Example 3
Source File: BottomSheetMediaActions.java    From Gallery-example with GNU General Public License v3.0 6 votes vote down vote up
private static void toggleBottomSheet(View bottomSheet) {

        BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);

        int state = bottomSheetBehavior.getState();

        switch (state) {
            case BottomSheetBehavior.STATE_COLLAPSED:
                bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
                break;
            case BottomSheetBehavior.STATE_HIDDEN:
                bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
                break;
            case BottomSheetBehavior.STATE_EXPANDED:
                bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
                break;

        }
    }
 
Example 4
Source File: BottomSheetActivity.java    From CoordinatorLayoutExample with Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.btnBehavior:
            int state = behavior.getState();
            if (state == BottomSheetBehavior.STATE_EXPANDED) {
                behavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
            } else if(state == BottomSheetBehavior.STATE_COLLAPSED){
                behavior.setState(BottomSheetBehavior.STATE_HIDDEN);
            }else if(state == BottomSheetBehavior.STATE_HIDDEN){
                behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
            }
            break;
        case R.id.btnDialog:
            BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this);
            bottomSheetDialog.setContentView(R.layout.include_bottom_sheet_layout);
            bottomSheetDialog.show();
            break;
        case R.id.btn_baidumap:
            readyGo(BaiduMapSample.class);
            break;
    }
}
 
Example 5
Source File: BottomSheetDialogScene.java    From scene with Apache License 2.0 5 votes vote down vote up
@Override
public void onStateChanged(@NonNull View bottomSheet,
                           @BottomSheetBehavior.State int newState) {
    if (newState == BottomSheetBehavior.STATE_HIDDEN) {
        cancel();
    }
}
 
Example 6
Source File: MainActivity.java    From ViewPrinter with Apache License 2.0 5 votes vote down vote up
@Override
public void onBackPressed() {
    BottomSheetBehavior b = BottomSheetBehavior.from(mPanel);
    if (b.getState() != BottomSheetBehavior.STATE_HIDDEN) {
        b.setState(BottomSheetBehavior.STATE_HIDDEN);
        return;
    }
    super.onBackPressed();
}
 
Example 7
Source File: TutsPlusBottomSheetDialogFragment.java    From AndroidDemoProjects with Apache License 2.0 5 votes vote down vote up
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
    if (newState == BottomSheetBehavior.STATE_HIDDEN) {
        dismiss();
    }

}
 
Example 8
Source File: BoxingBottomSheetActivity.java    From boxing with Apache License 2.0 5 votes vote down vote up
private boolean hideBottomSheet() {
    if (mBehavior != null && mBehavior.getState() != BottomSheetBehavior.STATE_HIDDEN) {
        mBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
        return true;
    }
    return false;
}
 
Example 9
Source File: BoxingBottomSheetActivity.java    From boxing with Apache License 2.0 5 votes vote down vote up
private void toggleBottomSheet() {
    if (mBehavior == null) {
        return;
    }
    if (mBehavior.getState() == BottomSheetBehavior.STATE_HIDDEN) {
        mBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
    } else {
        mBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
    }
}
 
Example 10
Source File: MyBottomSheetDialogFragment.java    From AndroidDesignWidgetsSample with Apache License 2.0 5 votes vote down vote up
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
    if (newState == BottomSheetBehavior.STATE_HIDDEN) {
        dismiss();
    }

}
 
Example 11
Source File: MaterialActivityChooserActivity.java    From material-activity-chooser with Apache License 2.0 4 votes vote down vote up
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
    if (newState == BottomSheetBehavior.STATE_HIDDEN) {
        finish();
    }
}
 
Example 12
Source File: ListOfNotificationsByRepositoriesFilterDialog.java    From ghwatch with Apache License 2.0 4 votes vote down vote up
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
  if (newState == BottomSheetBehavior.STATE_HIDDEN || newState == BottomSheetBehavior.STATE_COLLAPSED) {
    dismiss();
  }
}
 
Example 13
Source File: PostAction.java    From chaoli-forum-for-android-2 with GNU General Public License v3.0 4 votes vote down vote up
private void tryToShowSoftKeyboard(View view) {
    if (behavior.getState() == BottomSheetBehavior.STATE_COLLAPSED || behavior.getState() == BottomSheetBehavior.STATE_HIDDEN) {
        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.showSoftInput(view, InputMethodManager.SHOW_FORCED);
    }
}
 
Example 14
Source File: ReplyAction.java    From chaoli-forum-for-android-2 with GNU General Public License v3.0 4 votes vote down vote up
private void tryToShowSoftKeyboard(View view) {
	if (behavior.getState() == BottomSheetBehavior.STATE_COLLAPSED || behavior.getState() == BottomSheetBehavior.STATE_HIDDEN) {
		InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
		imm.showSoftInput(view, InputMethodManager.SHOW_FORCED);
	}
}
 
Example 15
Source File: CustomBottomSheetDialog.java    From ForPDA with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onStateChanged(@NonNull View bottomSheet, /*@BottomSheetBehavior.State*/ int newState) {
    if (newState == BottomSheetBehavior.STATE_HIDDEN) {
        cancel();
    }
}
 
Example 16
Source File: CustomBottomSheetDialogFragment.java    From ForPDA with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
    if (newState == BottomSheetBehavior.STATE_HIDDEN) {
        dismiss();
    }
}
 
Example 17
Source File: BaseBottomSheetDialog.java    From FastAccess with GNU General Public License v3.0 4 votes vote down vote up
@Override public void onStateChanged(@NonNull View bottomSheet, int newState) {
    if (newState == BottomSheetBehavior.STATE_HIDDEN) {
        isAlreadyHidden = true;
        onHidden();
    }
}
 
Example 18
Source File: ModalsBottomSheetDialogFragment.java    From OsmGo with MIT License 4 votes vote down vote up
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
  if (newState == BottomSheetBehavior.STATE_HIDDEN) {
    dismiss();
  }
}
 
Example 19
Source File: NavigationOnMoveListener.java    From graphhopper-navigation-android with MIT License 4 votes vote down vote up
@Override
public void onMoveEnd(MoveGestureDetector detector) {
  if (summaryBehavior.getState() != BottomSheetBehavior.STATE_HIDDEN) {
    navigationPresenter.onMapScroll();
  }
}
 
Example 20
Source File: NavigationView.java    From graphhopper-navigation-android with MIT License 4 votes vote down vote up
@Override
public boolean isSummaryBottomSheetHidden() {
  return summaryBehavior.getState() == BottomSheetBehavior.STATE_HIDDEN;
}