android.support.design.widget.BottomSheetBehavior Java Examples

The following examples show how to use android.support.design.widget.BottomSheetBehavior. 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: MainActivity.java    From AndroidWallet with GNU General Public License v3.0 7 votes vote down vote up
private void showAccountNotExistDialog(BaseInvokeModel baseInvokeModel, BaseInfo baseInfo) {
    bottomSheetDialog = new BottomSheetDialog(MainActivity.this);
    DialogAuthorAccountNotExistBinding binding = DataBindingUtil.inflate(LayoutInflater.from(Utils.getContext()), R.layout.dialog_author_account_not_exist, null, false);
    bottomSheetDialog.setContentView(binding.getRoot());
    // 设置dialog 完全显示
    View parent = (View) binding.getRoot().getParent();
    BottomSheetBehavior behavior = BottomSheetBehavior.from(parent);
    binding.getRoot().measure(0, 0);
    behavior.setPeekHeight(binding.getRoot().getMeasuredHeight());
    CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) parent.getLayoutParams();
    params.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;
    parent.setLayoutParams(params);
    bottomSheetDialog.setCanceledOnTouchOutside(false);
    final ConfrimDialogViewModel confrimDialogViewModel = new ConfrimDialogViewModel(getApplication());
    confrimDialogViewModel.setBaseInfo(baseInvokeModel, baseInfo);
    binding.setViewModel(confrimDialogViewModel);
    bottomSheetDialog.show();
}
 
Example #2
Source File: ConfigurationBottomSheet.java    From InstaTag with Apache License 2.0 6 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    BottomSheetDialog bottomSheetDialog = (BottomSheetDialog) super.onCreateDialog(savedInstanceState);
    bottomSheetDialog.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialog) {
            BottomSheetDialog bottomSheetDialog1 = (BottomSheetDialog) dialog;
            FrameLayout bottomSheet
                    = bottomSheetDialog1.findViewById(android.support.design.R.id.design_bottom_sheet);
            BottomSheetBehavior.from(bottomSheet).setState(BottomSheetBehavior.STATE_EXPANDED);
            BottomSheetBehavior.from(bottomSheet).setSkipCollapsed(true);
            BottomSheetBehavior.from(bottomSheet).setHideable(true);
        }
    });

    return bottomSheetDialog;
}
 
Example #3
Source File: BottomSheetMenu.java    From BottomSheetMenu with Apache License 2.0 6 votes vote down vote up
@SuppressLint("InflateParams")
private BottomSheetMenu(@NonNull Context context, BottomSheetMenuListener bottomSheetMenuListener) {
    super(context);
    mIconSize = context.getResources().getDimensionPixelSize(R.dimen.bottom_sheet_menu_item_icon_size);
    mBottomSheetMenuListener = bottomSheetMenuListener;

    setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialog) {
            BottomSheetDialog d = (BottomSheetDialog) dialog;
            FrameLayout bottomSheet = (FrameLayout) d.findViewById(android.support.design.R.id.design_bottom_sheet);

            if (bottomSheet != null) {
                BottomSheetBehavior.from(bottomSheet).setState(BottomSheetBehavior.STATE_EXPANDED);
            }
        }
    });
}
 
Example #4
Source File: AlarmDialog.java    From SuntimesWidget with GNU General Public License v3.0 6 votes vote down vote up
private void expandSheet(DialogInterface dialog)
{
    if (dialog == null) {
        return;
    }

    BottomSheetDialog bottomSheet = (BottomSheetDialog) dialog;
    FrameLayout layout = (FrameLayout) bottomSheet.findViewById(android.support.design.R.id.design_bottom_sheet);  // for AndroidX, resource is renamed to com.google.android.material.R.id.design_bottom_sheet
    if (layout != null)
    {
        BottomSheetBehavior behavior = BottomSheetBehavior.from(layout);
        behavior.setHideable(true);
        behavior.setSkipCollapsed(true);
        behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
    }
}
 
Example #5
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 #6
Source File: EditProfilePresenterImpl.java    From Saude-no-Mapa with MIT License 6 votes vote down vote up
private void setupBottomSheetDialog() {
    mBottomSheetDialog = new BottomSheetDialog(mContext);
    View dialogView = LayoutInflater.from(mContext)
            .inflate(R.layout.dialog_bottom_sheet_profile, null);

    RecyclerView avatarRecycler = (RecyclerView) dialogView.findViewById(R.id.avatar_recycler);
    avatarRecycler.setHasFixedSize(true);
    avatarRecycler.setLayoutManager(new GridLayoutManager(mContext, 3, GridLayoutManager.VERTICAL, false));

    avatarRecycler.setAdapter(new AvatarAdapter(mContext, this));

    mBottomSheetDialog.setContentView(dialogView);

    dialogView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);

    BottomSheetBehavior mBehavior = BottomSheetBehavior.from((View) dialogView.getParent());
    mBehavior.setPeekHeight(dialogView.getMeasuredHeight() + 200);

    mBottomSheetDialog.show();
}
 
Example #7
Source File: BottomSheetDialogScene.java    From scene with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    Window window = requireActivity().getWindow();
    if (window != null) {
        if (Build.VERSION.SDK_INT >= 21) {
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        }
        window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT);
    }

    requireNavigationScene().addOnBackPressedListener(this, new OnBackPressedListener() {
        @Override
        public boolean onBackPressed() {
            if (mBehavior.getState() != BottomSheetBehavior.STATE_COLLAPSED) {
                mBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
                return true;
            }
            return false;
        }
    });
}
 
Example #8
Source File: RegisterPresenterImpl.java    From Saude-no-Mapa with MIT License 6 votes vote down vote up
private void setupBottomSheetDialog() {
    mBottomSheetDialog = new BottomSheetDialog(mContext);
    View dialogView = LayoutInflater.from(mContext)
            .inflate(R.layout.dialog_bottom_sheet_profile, null);

    RecyclerView avatarRecycler = (RecyclerView) dialogView.findViewById(R.id.avatar_recycler);
    avatarRecycler.setHasFixedSize(true);
    avatarRecycler.setLayoutManager(new GridLayoutManager(mContext, 3, GridLayoutManager.VERTICAL, false));

    avatarRecycler.setAdapter(new AvatarAdapter(mContext, this));

    mBottomSheetDialog.setContentView(dialogView);

    dialogView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);

    BottomSheetBehavior mBehavior = BottomSheetBehavior.from((View) dialogView.getParent());
    mBehavior.setPeekHeight(dialogView.getMeasuredHeight() + 200);

    mBottomSheetDialog.show();
}
 
Example #9
Source File: MainActivity.java    From CircularReveal with MIT License 6 votes vote down vote up
@Override protected void onCreate(@Nullable Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  ButterKnife.bind(this);

  final ViewRevealManager revealManager = new ViewRevealManager();
  final SpringViewAnimatorManager springManager = new SpringViewAnimatorManager();
  springManager.setDampingRatio(SpringForce.DAMPING_RATIO_NO_BOUNCY);
  springManager.setStiffness(SpringForce.STIFFNESS_LOW);

  parent.setViewRevealManager(revealManager);

  settingsView.addSwitch("Enable Spring", false, new CompoundButton.OnCheckedChangeListener() {
    @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
      parent.setViewRevealManager(isChecked ? springManager : revealManager);
    }
  });
  settingsView.setAnimatorManager(springManager);

  final BottomSheetBehavior behavior = BottomSheetBehavior.from(settingsView);
  behavior.setPeekHeight(getResources().getDimensionPixelSize(R.dimen.bottom_peek_height));
  behavior.setSkipCollapsed(false);
  behavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
}
 
Example #10
Source File: FluentAppBar.java    From fluentAppBar with Apache License 2.0 6 votes vote down vote up
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    super.onLayout(changed, l, t, r, b);

    bottomSheetBehavior = BottomSheetBehavior.from(this);
    bottomSheetBehavior.setPeekHeight((int) getResources().getDimension(R.dimen.fluentappbar_bar_height));
    bottomSheetBehavior.setHideable(false);
    bottomSheetBehavior.setBottomSheetCallback(bottomSheetCallback);

    View moreIcon = findViewWithTag(MORE_ICON_TAG);
    moreIcon.setOnClickListener(onMoreClickListener);

    if (fluentAppBarType == FULL_FLUENT) {
        handleShowFluentBlur();
    }

    if (fluentAppBarType == DISABLE_FLUENT) {
        keepFluentRipple = false;
    }
}
 
Example #11
Source File: RouteAmapBusActivity.java    From BmapLite with Apache License 2.0 6 votes vote down vote up
private void getData() {
    mAmap = mMapView.getMap();
    mSearchInteracter = new SearchInteracter(this, TypeMap.TYPE_AMAP);

    mAmap.setOnMarkerClickListener(this);
    mAmap.setOnMapLoadedListener(this);
    mAmap.setOnCameraChangeListener(this);


    // 开启定位图层
    mAmap.setMyLocationEnabled(true);
    // 开启室内图
    mAmap.showIndoorMap(true);
    mAmap.setOnMyLocationChangeListener(this);
    mAmap.getUiSettings().setMyLocationButtonEnabled(false);

    Bundle bundle = getExtras();
    if (null != bundle) {
        mBusRoute = bundle.getParcelable("bus");
        mBusRouteResult = bundle.getParcelable("route");
    }

    mBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);

}
 
Example #12
Source File: MyBottomSheetDialogFragment.java    From AndroidDesignWidgetsSample with Apache License 2.0 6 votes vote down vote up
@Override
public void setupDialog(Dialog dialog, int style) {
    super.setupDialog(dialog, style);
    View contentView = View.inflate(getContext(), R.layout.my_bottom_sheet_dialog_fragment, null);
    dialog.setContentView(contentView);
    CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) ((View) contentView.getParent()).getLayoutParams();
    CoordinatorLayout.Behavior behavior = params.getBehavior();

    if (behavior != null && behavior instanceof BottomSheetBehavior) {
        bottomSheetBehavior = (BottomSheetBehavior) behavior;
        bottomSheetBehavior.setBottomSheetCallback(bottomSheetBehaviorCallback);
        bottomSheetBehavior.setPeekHeight(200);
    }


}
 
Example #13
Source File: BaseActivity.java    From africastalking-android with MIT License 6 votes vote down vote up
protected void showInfo(String header, String desc, @Nullable Drawable drawable, boolean error) {
    hideKeyboard();
    AppCompatTextView infoHeader = (AppCompatTextView) llBottomSheet.findViewById(R.id.info_header);
    AppCompatTextView infoDesc = (AppCompatTextView) llBottomSheet.findViewById(R.id.info_desc);
    AppCompatImageView infoImg = (AppCompatImageView) llBottomSheet.findViewById(R.id.info_img);
    if (error) {
        llBottomSheet.findViewById(R.id.info_img).setVisibility(View.GONE);
        ((AppCompatButton) findViewById(R.id.ok_dimiss)).setText("Close");
    } else {
        llBottomSheet.findViewById(R.id.info_img).setVisibility(View.VISIBLE);
        ((AppCompatButton) findViewById(R.id.ok_dimiss)).setText("Ok");
    }

    infoHeader.setText(header);
    infoDesc.setText(desc);
    if (drawable != null)
        infoImg.setImageDrawable(drawable);
    bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
}
 
Example #14
Source File: ImageStreamUi.java    From belvedere with Apache License 2.0 6 votes vote down vote up
private void initToolbar(final boolean fullScreenOnly) {
    toolbar.setNavigationIcon(R.drawable.belvedere_ic_close);
    toolbar.setNavigationContentDescription(R.string.belvedere_toolbar_desc_collapse);
    toolbar.setBackgroundColor(Color.WHITE);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if(!fullScreenOnly) {
                bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
            } else {
                dismiss();
            }
        }
    });

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        toolbarCompatShadow.setVisibility(View.VISIBLE);
    }

    CoordinatorLayout.LayoutParams layoutParams =
            (CoordinatorLayout.LayoutParams) toolbarContainer.getLayoutParams();

    if(layoutParams != null) {
        layoutParams.setBehavior(new ToolbarBehavior(!fullScreenOnly));
    }
}
 
Example #15
Source File: SecondActivity.java    From boxing with Apache License 2.0 5 votes vote down vote up
private void showFragment() {
    if (mInsideBottomSheet != null) {
        BottomSheetBehavior behavior = BottomSheetBehavior.from(mInsideBottomSheet);
        if (behavior.getState() != BottomSheetBehavior.STATE_EXPANDED) {
            behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
        } else {
            behavior.setState(BottomSheetBehavior.STATE_HIDDEN);
        }
    }
}
 
Example #16
Source File: BottomSheetBuilder.java    From BottomSheetBuilder with Apache License 2.0 5 votes vote down vote up
public View createView() {

        if (mMenu == null && mAdapterBuilder.getItems().isEmpty()) {
            throw new IllegalStateException("You need to provide at least one Menu " +
                    "or an item with addItem");
        }

        if (mCoordinatorLayout == null) {
            throw new IllegalStateException("You need to provide a coordinatorLayout" +
                    "so the view can be placed on it");
        }

        View sheet = mAdapterBuilder.createView(mTitleTextColor, mBackgroundDrawable,
                mBackgroundColor, mDividerBackground, mItemTextColor, mItemBackground,
                mIconTintColor, mItemClickListener);

        ViewCompat.setElevation(sheet, mContext.getResources()
                .getDimensionPixelSize(R.dimen.bottomsheet_elevation));

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            sheet.findViewById(R.id.fakeShadow).setVisibility(View.GONE);
        }

        CoordinatorLayout.LayoutParams layoutParams
                = new CoordinatorLayout.LayoutParams(CoordinatorLayout.LayoutParams.MATCH_PARENT,
                CoordinatorLayout.LayoutParams.WRAP_CONTENT);

        layoutParams.gravity = Gravity.CENTER_HORIZONTAL;
        layoutParams.setBehavior(new BottomSheetBehavior());

        if (mContext.getResources().getBoolean(R.bool.tablet_landscape)) {
            layoutParams.width = mContext.getResources()
                    .getDimensionPixelSize(R.dimen.bottomsheet_width);
        }

        mCoordinatorLayout.addView(sheet, layoutParams);
        mCoordinatorLayout.postInvalidate();
        return sheet;
    }
 
Example #17
Source File: SecondActivity.java    From boxing with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_second);
    createToolbar();
    findViewById(R.id.inside_bs_btn).setOnClickListener(this);
    mResultImg = (ImageView) findViewById(R.id.media_result);
    mResultImg.setOnClickListener(this);
    mInsideBottomSheet = (FrameLayout) findViewById(R.id.content_layout);
    BoxingBottomSheetFragment fragment = (BoxingBottomSheetFragment) getSupportFragmentManager().
            findFragmentByTag(BoxingBottomSheetFragment.TAG);
    if (fragment == null) {
        fragment = BoxingBottomSheetFragment.newInstance();
        getSupportFragmentManager().beginTransaction()
                .add(R.id.content_layout, fragment, BoxingBottomSheetFragment.TAG).commit();

        BoxingConfig singleImgConfig = new BoxingConfig(BoxingConfig.Mode.SINGLE_IMG)
                .withMediaPlaceHolderRes(R.drawable.ic_boxing_default_image).withAlbumPlaceHolderRes(R.drawable.ic_boxing_default_image);
        Boxing.of(singleImgConfig).setupFragment(fragment, new Boxing.OnBoxingFinishListener() {

            @Override
            public void onBoxingFinish(Intent intent, List<BaseMedia> medias) {
                BottomSheetBehavior behavior = BottomSheetBehavior.from(mInsideBottomSheet);
                behavior.setState(BottomSheetBehavior.STATE_HIDDEN);
                if (medias != null && medias.size() > 0) {
                    BaseMedia media = mMedia = medias.get(0);
                    String path = media.getPath();
                    BoxingMediaLoader.getInstance().displayRaw(mResultImg, path, 1080, 720, null);
                }
            }
        });
    } else {
        fragment.setPresenter(new PickerPresenter(fragment));
    }
}
 
Example #18
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 #19
Source File: BoxingBottomSheetActivity.java    From boxing with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_boxing_bottom_sheet);
    createToolbar();

    FrameLayout bottomSheet = (FrameLayout) findViewById(R.id.content_layout);
    mBehavior = BottomSheetBehavior.from(bottomSheet);
    mBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);

    mImage = (ImageView) findViewById(R.id.media_result);
    mImage.setOnClickListener(this);
}
 
Example #20
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 #21
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 #22
Source File: BottomSheetCoordinatorLayout.java    From BottomSheetCoordinatorLayout with Apache License 2.0 5 votes vote down vote up
/**
 * Set a {@link android.support.design.widget.BottomSheetBehavior.BottomSheetCallback} callback
 * to our behavior, as soon as it is available.
 *
 * @param bottomSheetCallback desired callback.
 */
public void setBottomSheetCallback(final BottomSheetBehavior.BottomSheetCallback bottomSheetCallback) {
    if (bottomSheetBehavior == null) {
        delayedBottomSheetCallback = bottomSheetCallback;
    } else {
        bottomSheetBehavior.setBottomSheetCallback(bottomSheetCallback);
    }
}
 
Example #23
Source File: PicDialog.java    From PicKing with Apache License 2.0 5 votes vote down vote up
public PicDialog(Context context) {
    super(context, R.style.AppNoActionBarTheme);
    setOwnerActivity((Activity) context);
    setContentView(R.layout.dialog_pic);

    StatusBarUtil.MIUISetStatusBarLightMode(getOwnerActivity(), true);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        View decorView = getWindow().getDecorView();
        int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
        decorView.setSystemUiVisibility(option);
        getWindow().setStatusBarColor(Color.TRANSPARENT);
    }

    ButterKnife.bind(this);

    if ((boolean) SPUtils.get(getContext(), AppConfig.click_to_back, false))
        photoDraweeView.setOnViewTapListener(new OnViewTapListener() {
            @Override
            public void onViewTap(View view, float x, float y) {
                dismiss();
            }
        });

    photoDraweeView.setAllowParentInterceptOnEdge(false);
    photoDraweeView.setEnableDraweeMatrix(false);

    for (AppCompatImageButton imageButton : imageButtons)
        imageButton.setOnClickListener(this);

    getWindow().setWindowAnimations(R.style.dialogStyle);

    behavior = BottomSheetBehavior.from(findViewById(R.id.bottom_view));
}
 
Example #24
Source File: LocationAlarmActivity.java    From LocationAware with Apache License 2.0 5 votes vote down vote up
@Override
public void showBottomSheet() {
  if (mBottomSheetBehavior.getState() != BottomSheetBehavior.STATE_EXPANDED) {
    mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
  } else {
    mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
  }
}
 
Example #25
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 #26
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 #27
Source File: MainActivity.java    From ViewPrinter with Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(View view) {
    switch (view.getId()) {
        case R.id.print_jpeg: print(PRINT_JPEG); break;
        case R.id.print_pdf: print(PRINT_PDF); break;
        case R.id.print_png: print(PRINT_PNG); break;
        case R.id.edit:
            BottomSheetBehavior b = BottomSheetBehavior.from(mPanel);
            b.setState(BottomSheetBehavior.STATE_COLLAPSED);
            break;
        case R.id.logo_prompt:
            startActivity(new Intent(this, LogoActivity.class));
            break;
    }
}
 
Example #28
Source File: CitySearchBottomSheetDialogFragment.java    From Travel-Mate with MIT License 5 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = super.onCreateDialog(savedInstanceState);

    dialog.setOnShowListener(dialog1 -> {
        View bottomSheet = ((BottomSheetDialog) dialog1)
                .findViewById(android.support.design.R.id.design_bottom_sheet);

        BottomSheetBehavior.from(bottomSheet)
                .setPeekHeight(Resources.getSystem().getDisplayMetrics().heightPixels);
    });

    return dialog;
}
 
Example #29
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 #30
Source File: NavigationPresenter.java    From graphhopper-navigation-android with MIT License 5 votes vote down vote up
void onMapScroll() {
  if (!view.isSummaryBottomSheetHidden()) {
    view.setSummaryBehaviorHideable(true);
    view.setSummaryBehaviorState(BottomSheetBehavior.STATE_HIDDEN);
    view.updateCameraTrackingEnabled(false);
    view.updateWaynameVisibility(false);
  }
}