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

The following examples show how to use android.support.design.widget.BottomSheetBehavior#STATE_COLLAPSED . 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: 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 2
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 3
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 4
Source File: FluentAppBar.java    From fluentAppBar with Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(View v) {

    if (bottomSheetBehavior.getState() == BottomSheetBehavior.STATE_COLLAPSED) {
        bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
    } else {
        bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
    }
}
 
Example 5
Source File: FluentAppBar.java    From fluentAppBar with Apache License 2.0 5 votes vote down vote up
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
    if (fluentAppBarType == CLICK_FLUENT) {
        if (newState == BottomSheetBehavior.STATE_EXPANDED) {
            handleShowFluentBlur();
        } else if (newState == BottomSheetBehavior.STATE_COLLAPSED) {
            BlurView blurView = (BlurView) findViewById(R.id.blurview);
            blurView.setBlurEnabled(false);
            setBackgroundColor(backgroundColour);
        }
    }
}
 
Example 6
Source File: BoxingBottomSheetActivity.java    From boxing with Apache License 2.0 5 votes vote down vote up
private boolean collapseBottomSheet() {
    if (mBehavior != null && mBehavior.getState() != BottomSheetBehavior.STATE_COLLAPSED) {
        mBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
        return true;
    }
    return false;
}
 
Example 7
Source File: DetailsActivity.java    From AndroidDesignWidgetsSample with Apache License 2.0 5 votes vote down vote up
@OnClick(R.id.card_item_1)
void showBottomSheet() {
    int lastState = bottomSheetBehavior.getState();
    switch (lastState) {
        case BottomSheetBehavior.STATE_COLLAPSED:
            bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
            break;
        case BottomSheetBehavior.STATE_EXPANDED:
            bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
            break;
        case BottomSheetBehavior.STATE_HIDDEN:
            bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
            break;
    }
}
 
Example 8
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 9
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 10
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();
  }
}