android.support.design.widget.BottomSheetDialog Java Examples

The following examples show how to use android.support.design.widget.BottomSheetDialog. 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: LightMapDialog.java    From SuntimesWidget with GNU General Public License v3.0 6 votes vote down vote up
private void expandSheet(DialogInterface dialog)
{
    if (dialog != null) {
        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(false);
            behavior.setSkipCollapsed(true);
            behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
        }
    }
}
 
Example #3
Source File: TimeZoneDialog.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 #4
Source File: LocationConfigDialog.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(false);
        behavior.setSkipCollapsed(true);
        behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
    }
}
 
Example #5
Source File: TimeDateDialog.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(false);
        behavior.setSkipCollapsed(true);
        behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
    }
}
 
Example #6
Source File: MoonDialog.java    From SuntimesWidget with GNU General Public License v3.0 6 votes vote down vote up
private void initPeekHeight(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);
        ViewGroup dialogLayout = (LinearLayout) bottomSheet.findViewById(R.id.moondialog_layout);
        View divider1 = bottomSheet.findViewById(R.id.divider1);
        if (dialogLayout != null && divider1 != null)
        {
            Rect headerBounds = new Rect();
            divider1.getDrawingRect(headerBounds);
            dialogLayout.offsetDescendantRectToMyCoords(divider1, headerBounds);
            behavior.setPeekHeight(headerBounds.top);

        } else {
            behavior.setPeekHeight(-1);
        }
    }
}
 
Example #7
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 #8
Source File: MoonDialog.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(false);
        behavior.setSkipCollapsed(true);
        behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
    }
}
 
Example #9
Source File: LightMapDialog.java    From SuntimesWidget with GNU General Public License v3.0 6 votes vote down vote up
private void initPeekHeight(DialogInterface dialog)
{
    if (dialog != null) {
        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);
            ViewGroup dialogLayout = (ViewGroup) bottomSheet.findViewById(R.id.dialog_lightmap_layout);
            View divider1 = bottomSheet.findViewById(R.id.info_time_lightmap);
            if (dialogLayout != null && divider1 != null)
            {
                Rect headerBounds = new Rect();
                divider1.getDrawingRect(headerBounds);
                dialogLayout.offsetDescendantRectToMyCoords(divider1, headerBounds);
                behavior.setPeekHeight(headerBounds.bottom + (int)getResources().getDimension(R.dimen.dialog_margin));

            } else {
                behavior.setPeekHeight(-1);
            }
        }
    }
}
 
Example #10
Source File: MainActivity.java    From Android-Tutorials with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    bottomSheetDialog = new BottomSheetDialog(MainActivity.this);
    View bottomSheetDialogView = getLayoutInflater().inflate(R.layout.dialog_layout, null);
    bottomSheetDialog.setContentView(bottomSheetDialogView);

    View shareView = bottomSheetDialogView.findViewById(R.id.share);
    View getLinkView = bottomSheetDialogView.findViewById(R.id.get_link);
    View editNameView = bottomSheetDialogView.findViewById(R.id.edit_name);
    View deleteView = bottomSheetDialogView.findViewById(R.id.delete);

    shareView.setOnClickListener(this);
    getLinkView.setOnClickListener(this);
    editNameView.setOnClickListener(this);
    deleteView.setOnClickListener(this);

    Button button = findViewById(R.id.main_show_bottom_sheet_dialog);
    button.setOnClickListener(this);

}
 
Example #11
Source File: FunctionButtonBar.java    From alpha-wallet-android with MIT License 6 votes vote down vote up
private void initializeViews() {

        primaryButton = findViewById(R.id.primary_button);
        secondaryButton = findViewById(R.id.secondary_button);
        moreButton = findViewById(R.id.more_button);

        bottomSheet = new BottomSheetDialog(getContext());
        bottomSheet.setCancelable(true);
        bottomSheet.setCanceledOnTouchOutside(true);
        moreActionsListView = new ListView(getContext());
        moreActionsList = new ArrayList<>();
        moreActionsAdapter = new FunctionItemAdapter(getContext(),
                R.layout.item_action, moreActionsList);
        moreActionsListView.setAdapter(moreActionsAdapter);
        bottomSheet.setContentView(moreActionsListView);
        moreActionsListView.setOnItemClickListener(this);
        moreActionsListView.setDivider(new ColorDrawable(ContextCompat.getColor(context, R.color.mercury)));
        moreActionsListView.setDividerHeight(Utils.dp2px(context, 1));
    }
 
Example #12
Source File: WorldMapDialog.java    From SuntimesWidget with GNU General Public License v3.0 6 votes vote down vote up
private void collapseSheet(Dialog dialog)
{
    if (dialog == null) {
        return;
    }

    BottomSheetDialog bottomSheet = (BottomSheetDialog) dialog;
    FrameLayout layout = (FrameLayout) bottomSheet.findViewById(android.support.design.R.id.design_bottom_sheet);
    if (layout != null)
    {
        BottomSheetBehavior behavior = BottomSheetBehavior.from(layout);
        behavior.setHideable(false);
        behavior.setSkipCollapsed(false);
        behavior.setPeekHeight((int)(dialogHeader.getHeight() + getResources().getDimension(R.dimen.dialog_margin) * 2));
        behavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
    }
}
 
Example #13
Source File: WorldMapDialog.java    From SuntimesWidget with GNU General Public License v3.0 6 votes vote down vote up
private void expandSheet(Dialog dialog)
{
    if (dialog == null) {
        return;
    }

    BottomSheetDialog bottomSheet = (BottomSheetDialog) dialog;
    FrameLayout layout = (FrameLayout) bottomSheet.findViewById(android.support.design.R.id.design_bottom_sheet);
    if (layout != null)
    {
        BottomSheetBehavior behavior = BottomSheetBehavior.from(layout);
        behavior.setHideable(false);
        behavior.setSkipCollapsed(true);
        behavior.setPeekHeight((int)(dialogHeader.getHeight() + getResources().getDimension(R.dimen.dialog_margin) * 2));
        behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
    }
}
 
Example #14
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 #15
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 #16
Source File: AboutDialog.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(false);
        behavior.setSkipCollapsed(true);
        behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
    }
}
 
Example #17
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 #18
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 #19
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 #20
Source File: AssetFragment.java    From AndroidWallet with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void initViewObservable() {
    viewModel.uc.accountItemObservable.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
        @Override
        public void onPropertyChanged(Observable sender, int propertyId) {
            dialog = new BottomSheetDialog(activity,R.style.BottomSheetDialog);
            DialogSwitchAccountBinding binding = DataBindingUtil.inflate(LayoutInflater.from(Utils.getContext()), R.layout.dialog_switch_account, null, false);
            dialog.setContentView(binding.getRoot());
            binding.setViewModel(new SwitchAccountViewModel((Application) Utils.getContext()));
            dialog.setCanceledOnTouchOutside(true);
            dialog.show();
        }
    });
}
 
Example #21
Source File: BottomSheetHolder.java    From DialogUtil with Apache License 2.0 5 votes vote down vote up
private void setMdBottomSheetDialogBehaviour(AdapterView adapterView, Context context, final ConfigBean bean) {
    if(bean.hasBehaviour && bean.dialog instanceof BottomSheetDialog){
        //Tool.handleScrollInBottomSheetDialog(listView);
        if(adapterView !=null){
            Tool.handleScrollInBottomSheetDialog(adapterView);
        }

        //

    }
}
 
Example #22
Source File: DialogViewBuilder.java    From DialogUtil with Apache License 2.0 5 votes vote down vote up
private void buildBottomSheet(ConfigBean bean) {
    final BottomSheetDialog dialog = new BottomSheetDialog(bean.context);
    Tool.removeFromParent(bean.customView);
    dialog.setContentView(bean.customView);
    bean.forceWidthPercent = 1.0f;
    dialog.setCancelable(bean.cancelable);
    dialog.setCanceledOnTouchOutside(bean.outsideTouchable);
    bean.dialog = dialog;
}
 
Example #23
Source File: HelpDialog.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
private void expandSheet(DialogInterface dialog)
{
    if (dialog != null) {
        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(false);
            behavior.setSkipCollapsed(false);
            behavior.setPeekHeight(200);
            behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
        }
    }
}
 
Example #24
Source File: BaseActivity.java    From android-md-core with Apache License 2.0 5 votes vote down vote up
protected void showThemePicker() {
  BottomSheetDialog dialog = new BottomSheetDialog(this);
  View view = getLayoutInflater().inflate(R.layout.custom_color_dialog, null, false);
  RecyclerView recyclerView = (RecyclerView) view.findViewById(android.R.id.list);
  recyclerView.setLayoutManager(new GridLayoutManager(this, 3));
  recyclerView.setAdapter(new ThemeAdapter((v, id) -> ThemeUtils.changeToTheme(this, id)));
  dialog.setContentView(view);
  dialog.show();
}
 
Example #25
Source File: EquinoxDialog.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
private void expandSheet(DialogInterface dialog)
{
    if (dialog != null)
    {
        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 #26
Source File: BottomSheetLogView.java    From bleYan with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param context
 */
public BottomSheetLogView(Context context, List<String> logInfoList) {
    mDialog = new BottomSheetDialog(context);
    View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_log_recycler_view, null);

    RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.bottom_sheet_recycler_view);
    recyclerView.setLayoutManager(new LinearLayoutManager(context));
    mAdapter = new BleLogAdapter(logInfoList);
    recyclerView.setAdapter(mAdapter);

    mDialog.setContentView(view);
    mDialog.show();
}
 
Example #27
Source File: LoginPresenterImpl.java    From Saude-no-Mapa with MIT License 5 votes vote down vote up
@Override
public void onReactivateAccountClicked() {
    mIsValidationFromDialog = true;
    mBottomSheetDialog = new BottomSheetDialog(mContext);

    View dialogView = LayoutInflater.from(mContext).inflate(R.layout.dialog_bottom_sheet_reactivate_account, null);
    mBottomViews = new ReactivateViews();
    ButterKnife.bind(mBottomViews, dialogView);

    mInteractor.validateReactivateForms(mBottomViews.loginEmailEdit, mBottomViews.loginPasswordEdit, this);

    mBottomViews.loginGoogleButton.setSize(SignInButton.SIZE_STANDARD);
    mBottomViews.loginGoogleButton.setScopes(mGso.getScopeArray());

    mBottomViews.filterButton.setOnClickListener(v -> {
        requestReactivateNormalAccount();
    });

    mBottomViews.loginGoogleButton.setOnClickListener(v -> {
        googleLoginClicked();
    });

    mBottomViews.loginFacebookButton.setOnClickListener(v -> {
        facebookLoginClicked();
    });

    mBottomSheetDialog.setContentView(dialogView);

    mBottomViews.bottomSheet.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);

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

    mBottomSheetDialog.setOnDismissListener(dialog -> {
        mIsValidationFromDialog = false;
    });

    mBottomSheetDialog.show();
}
 
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: MyBottomSheetDialogFragment.java    From AndroidSamples with Apache License 2.0 5 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
    BottomSheetDialog dialog = (BottomSheetDialog) super.onCreateDialog(savedInstanceState);
    View view = View.inflate(getContext(), R.layout.dialog_bottom_sheet, null);
    dialog.setContentView(view);
    mBehavior = BottomSheetBehavior.from((View) view.getParent());
    return dialog;
}
 
Example #30
Source File: MainActivity.java    From AndroidSamples with Apache License 2.0 5 votes vote down vote up
@Override
public void showBottomSheetDialog() {
    View v = View.inflate(this, R.layout.sheet_dialog, null);
    mBottomSheetDialog = new BottomSheetDialog(this);
    mBottomSheetDialog.setContentView(v);
    Button btn_enter = v.findViewById(R.id.btn_enter);
    final EditText et_xh = v.findViewById(R.id.et_xh);
    final EditText et_name = v.findViewById(R.id.et_name);
    final EditText et_age = v.findViewById(R.id.et_sex);
    final EditText et_address = v.findViewById(R.id.et_address);

    btn_enter.setOnClickListener(view -> {

        long xh = 0;
        try {
            xh = Long.parseLong(et_xh.getText().toString().trim());
        } catch (NumberFormatException e) {
            Toast.makeText(MainActivity.this, "学号请输入数字", Toast.LENGTH_SHORT).show();
            return;
        }

        String name = et_name.getText().toString().trim();
        String age = et_age.getText().toString().trim();
        String address = et_address.getText().toString().trim();

        if (xh == 0 || name.isEmpty() || age.isEmpty() || address.isEmpty()) {
            Toast.makeText(MainActivity.this, "内容不能为空", Toast.LENGTH_SHORT).show();
            mBottomSheetDialog.dismiss();
            return;
        }
        Student student = new Student(xh, name, age, address);

        mainPresenter.OnCreateData(student);

    });
    mBottomSheetDialog.show();
}