Java Code Examples for android.support.design.widget.BottomSheetDialog#setOnDismissListener()

The following examples show how to use android.support.design.widget.BottomSheetDialog#setOnDismissListener() . 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: 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 2
Source File: EstablishmentPresenterImpl.java    From Saude-no-Mapa with MIT License 4 votes vote down vote up
private void showFilterBottomSheetDialog() {
    mIsFiltered = false;
    BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(mContext);
    View dialogView = LayoutInflater.from(mContext).inflate(R.layout.dialog_bottom_sheet_filter, null);
    FilterViews bottomViews = new FilterViews();
    ButterKnife.bind(bottomViews, dialogView);

    mCurrentFilterTitle = bottomViews.filterTitle;
    updateCurrentFilterTitle();

    bottomViews.redeAtendimentoSpinner.setAdapter(getRedeAtendimentoAdapter());
    bottomViews.categoriaSpinner.setAdapter(getCategoriaSpinner());

    RxAdapterView.itemSelections(bottomViews.redeAtendimentoSpinner).subscribe(integer -> {
        doFilter(bottomViews);
    });

    RxAdapterView.itemSelections(bottomViews.categoriaSpinner).subscribe(integer -> {
        doFilter(bottomViews);
    });

    RxCompoundButton.checkedChanges(bottomViews.vinculoSusCheckbox).subscribe(isChecked -> {
        doFilter(bottomViews);
    });

    RxCompoundButton.checkedChanges(bottomViews.atendimentoUrgencialCheckbox).subscribe(isChecked -> {
        doFilter(bottomViews);
    });

    RxCompoundButton.checkedChanges(bottomViews.atendimentoAmbulatorialCheckbox).subscribe(isChecked -> {
        doFilter(bottomViews);
    });

    RxCompoundButton.checkedChanges(bottomViews.centroCirurgicoCheckbox).subscribe(isChecked -> {
        doFilter(bottomViews);
    });

    RxCompoundButton.checkedChanges(bottomViews.obstetraCheckbox).subscribe(isChecked -> {
        doFilter(bottomViews);
    });

    RxCompoundButton.checkedChanges(bottomViews.neoNatalCheckbox).subscribe(isChecked -> {
        doFilter(bottomViews);
    });

    RxCompoundButton.checkedChanges(bottomViews.dialiseCheckbox).subscribe(isChecked -> {
        doFilter(bottomViews);
    });

    bottomViews.filterButton.setOnClickListener(view -> {
        mIsFiltered = true;
        mInteractor.clearMarkers(mMap);
        showMapPins(mFilteredEstablishmentList);
        mInteractor.animateCameraToAllEstablishments(mMap);
        bottomSheetDialog.dismiss();
    });

    bottomSheetDialog.setContentView(dialogView);
    bottomSheetDialog.getWindow().findViewById(R.id.design_bottom_sheet)
            .setBackgroundResource(R.color.default_dialog_background);

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

    BottomSheetBehavior mBehavior = BottomSheetBehavior.from((View) dialogView.getParent());
    mBehavior.setPeekHeight((int) (mView.getMapContainerHeight() + 400));

    bottomSheetDialog.setOnDismissListener(dialogInterface -> {
        if (!mIsFiltered) {
            mFilteredEstablishmentList.clear();
            mFilteredEstablishmentList.addAll(mEstablishmentList);
        }
    });

    bottomSheetDialog.show();
}
 
Example 3
Source File: EmergencyPresenterImpl.java    From Saude-no-Mapa with MIT License 4 votes vote down vote up
private void showEstablishmentBottomDialog(Establishment establishment) {
    if (establishment == null) {
        return;
    }
    BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(mContext);

    View dialogView = LayoutInflater.from(mContext).inflate(R.layout.dialog_bottom_sheet_marker, null);
    MarkerViews bottomViews = new MarkerViews();
    ButterKnife.bind(bottomViews, dialogView);

    mRatingView = bottomViews.ratingView;
    mRatingView.setIndicator(true);
    mEstablishmentProgress = bottomViews.establishmentProgress;
    mEstablishmentProgress.setVisibility(View.VISIBLE);

    bottomViews.establishmentTitle.setText(GenericUtil.capitalize(establishment.getNomeFantasia().toLowerCase()));
    bottomViews.descricaoCompletaText.setText(GenericUtil.capitalize(establishment.getDescricaoCompleta().toLowerCase()));
    bottomViews.enderecoText.setText(mInteractor.getAddressText(establishment.getLogradouro(), establishment.getNumero(),
            establishment.getBairro(), establishment.getCidade(), establishment.getUf(), establishment.getCep()));
    if (TextUtils.isEmpty(establishment.getTelefone())) {
        bottomViews.phoneLayout.setVisibility(View.GONE);
    } else {
        bottomViews.phoneText.setText(establishment.getTelefone());
    }
    bottomViews.turnoAtendimento.setText(establishment.getTurnoAtendimento());
    bottomViews.tipoUnidadeText.setText(GenericUtil.capitalize(establishment.getTipoUnidade().toLowerCase()));
    bottomViews.redeAtendimentoText.setText(GenericUtil.capitalize(establishment.getEsferaAdministrativa().toLowerCase()));
    bottomViews.vinculoSusText.setText(GenericUtil.capitalize(establishment.getVinculoSus().toLowerCase()));
    bottomViews.fluxoClientelaText.setText(mInteractor.getFluxoClientelaText(establishment.getFluxoClientela()));
    bottomViews.cnpjText.setText(establishment.getCnpj());
    bottomViews.servicesText.setText(mInteractor.getServicesText(establishment));
    bottomViews.enderecoText.setOnClickListener(view -> {
        showGoToAddressDialog(establishment.getLatitude(), establishment.getLongitude());
    });

    bottomViews.phoneText.setOnClickListener(v -> {
        showCallToPhoneDialog(establishment.getTelefone());
    });

    if (mInteractor.isEstablishmentLiked(Long.valueOf(establishment.getCodUnidade()))) {
        bottomViews.likeImage.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_like_filled));
    }

    bottomViews.groupImage.setOnClickListener(v -> {
        Intent intent = new Intent(mContext, GroupActivity.class);
        intent.putExtra(ESTABLISHMENT_INTENT_KEY, establishment.getNomeFantasia());
        mView.goToActivity(intent);
    });

    isLiked = mInteractor.isEstablishmentLiked(Long.valueOf(establishment.getCodUnidade()));
    bottomViews.likeImage.setOnClickListener(v -> {
        mEstablishmentProgress.setVisibility(View.VISIBLE);
        if (isLiked) {
            mSubscription.add(mInteractor.requestDisLikeEstablishment(establishment.getCodUnidade())
                    .observeOn(AndroidSchedulers.mainThread())
                    .onErrorReturn(throwable -> null)
                    .subscribe(responseBodyResponse -> {
                        mEstablishmentProgress.setVisibility(View.GONE);
                        if (responseBodyResponse != null && responseBodyResponse.isSuccessful()) {
                            isLiked = false;
                            mInteractor.removeDislikedContentCode();
                            bottomViews.likeImage.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_like_empty));
                        } else {
                            mView.showToast(mContext.getString(R.string.http_error_generic));
                        }
                    }));
        } else {
            requestLikeEstablishment(Long.valueOf(establishment.getCodUnidade()), bottomViews.likeImage);
        }
    });

    bottomSheetDialog.setContentView(dialogView);
    bottomSheetDialog.getWindow().findViewById(R.id.design_bottom_sheet)
            .setBackgroundResource(R.color.default_dialog_background);

    bottomViews.mainInfoCard.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);

    BottomSheetBehavior mBehavior = BottomSheetBehavior.from((View) dialogView.getParent());
    mBehavior.setPeekHeight(bottomViews.mainInfoCard.getMeasuredHeight() + 115);

    bottomSheetDialog.setOnDismissListener(dialogInterface -> {
        lastOpenned.hideInfoWindow();
    });

    bottomSheetDialog.show();
}
 
Example 4
Source File: FavEstablishmentPresenterImpl.java    From Saude-no-Mapa with MIT License 4 votes vote down vote up
private void showEstablishmentBottomDialog(Establishment establishment) {
        if (establishment == null) {
            return;
        }
        BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(mContext);

        View dialogView = LayoutInflater.from(mContext).inflate(R.layout.dialog_bottom_sheet_marker, null);
        MarkerViews bottomViews = new MarkerViews();
        ButterKnife.bind(bottomViews, dialogView);

        mRatingView = bottomViews.ratingView;
        mRatingView.setIndicator(true);
        mEstablishmentProgress = bottomViews.establishmentProgress;
//        mEstablishmentProgress.setVisibility(View.VISIBLE);

        bottomViews.establishmentTitle.setText(GenericUtil.capitalize(establishment.getNomeFantasia().toLowerCase()));
        bottomViews.descricaoCompletaText.setText(GenericUtil.capitalize(establishment.getDescricaoCompleta().toLowerCase()));
        bottomViews.enderecoText.setText(mInteractor.getAddressText(establishment.getLogradouro(), establishment.getNumero(),
                establishment.getBairro(), establishment.getCidade(), establishment.getUf(), establishment.getCep()));
        if (TextUtils.isEmpty(establishment.getTelefone())) {
            bottomViews.phoneLayout.setVisibility(View.GONE);
        } else {
            bottomViews.phoneText.setText(establishment.getTelefone());
        }
        bottomViews.turnoAtendimento.setText(establishment.getTurnoAtendimento());
        bottomViews.tipoUnidadeText.setText(GenericUtil.capitalize(establishment.getTipoUnidade().toLowerCase()));
        bottomViews.redeAtendimentoText.setText(GenericUtil.capitalize(establishment.getEsferaAdministrativa().toLowerCase()));
        bottomViews.vinculoSusText.setText(GenericUtil.capitalize(establishment.getVinculoSus().toLowerCase()));
        bottomViews.fluxoClientelaText.setText(mInteractor.getFluxoClientelaText(establishment.getFluxoClientela()));
        bottomViews.cnpjText.setText(establishment.getCnpj());
        bottomViews.servicesText.setText(mInteractor.getServicesText(establishment));
        bottomViews.enderecoText.setOnClickListener(view -> {
            showGoToAddressDialog(establishment.getLatitude(), establishment.getLongitude());
        });

        bottomViews.phoneText.setOnClickListener(v -> {
            showCallToPhoneDialog(establishment.getTelefone());
        });

        bottomViews.groupImage.setOnClickListener(v -> {
            Intent intent = new Intent(mContext, GroupActivity.class);
            intent.putExtra(ESTABLISHMENT_INTENT_KEY, establishment.getNomeFantasia());
            mView.goToActivity(intent);
        });

        isLiked = true;
        bottomViews.likeImage.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_like_filled));
        bottomViews.likeImage.setOnClickListener(v -> {
            mEstablishmentProgress.setVisibility(View.VISIBLE);
            if (isLiked) {
                mSubscription.add(mInteractor.requestDislikeEstablishment(Long.valueOf(establishment.getCodUnidade()))
                        .observeOn(AndroidSchedulers.mainThread())
                        .onErrorReturn(throwable -> null)
                        .subscribe(responseBodyResponse -> {
                            mEstablishmentProgress.setVisibility(View.GONE);
                            if (responseBodyResponse != null && responseBodyResponse.isSuccessful()) {
                                isLiked = false;
                                mInteractor.removeDislikedContentCode();
                                bottomViews.likeImage.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_like_empty));
                            } else {
                                mView.showToast(mContext.getString(R.string.http_error_generic));
                            }
                        }));
            } else {
                requestLikeEstablishment(Long.valueOf(establishment.getCodUnidade()), bottomViews.likeImage);
            }
        });

        bottomSheetDialog.setContentView(dialogView);
        bottomSheetDialog.getWindow().findViewById(R.id.design_bottom_sheet)
                .setBackgroundResource(R.color.default_dialog_background);

        bottomViews.mainInfoCard.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);

        BottomSheetBehavior mBehavior = BottomSheetBehavior.from((View) dialogView.getParent());
        mBehavior.setPeekHeight(bottomViews.mainInfoCard.getMeasuredHeight() + 115);

        bottomSheetDialog.setOnDismissListener(dialogInterface -> {
            if (mInteractor.getLikedEstablishmentCount() < mAdapterCountAfterFetching) {
                requestFavEstablishments();
            }
        });

        bottomSheetDialog.show();
    }
 
Example 5
Source File: FavRemedyPresenterImpl.java    From Saude-no-Mapa with MIT License 4 votes vote down vote up
private void showRemedyBottomDialog(Remedy remedy) {
    BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(mContext);
    View dialogView = LayoutInflater.from(mContext).inflate(R.layout.dialog_bottom_sheet_remedy, null);
    BottomViews bottomViews = new BottomViews();
    ButterKnife.bind(bottomViews, dialogView);

    mRemedyProgress = bottomViews.remedyProgress;

    bottomViews.priceText.setText("R$ " + String.format(Locale.getDefault(), "%.2f", remedy.getPmc0()) + " a " +
            "R$ " + String.format(Locale.getDefault(), "%.2f", remedy.getPmc20()));
    bottomViews.establishmentTitle.setText(GenericUtil.capitalize(remedy.getProduto().toLowerCase()));
    bottomViews.apresentacaoText.setText(GenericUtil.capitalize(remedy.getApresentacao().toLowerCase()));
    bottomViews.classeTerapeuticaText.setText(GenericUtil.capitalize(remedy.getClasseTerapeutica().toLowerCase()));
    bottomViews.laboratorioText.setText(GenericUtil.capitalize(remedy.getLaboratorio().toLowerCase()));
    bottomViews.principioAtivoText.setText(GenericUtil.capitalize(remedy.getPrincipioAtivo().toLowerCase()));
    bottomViews.registroText.setText(remedy.getRegistro());
    bottomViews.cnpjText.setText(remedy.getCnpj());

    if (remedy.getRestricao().equals("Sim")) {
        bottomViews.possuiRestricaoText.setVisibility(View.VISIBLE);
    }

    bottomViews.likeImage.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_like_filled));
    isLiked = true;
    bottomViews.likeImage.setOnClickListener(v -> {
        mRemedyProgress.setVisibility(View.VISIBLE);
        if (isLiked) {
            mSubscription.add(mInteractor.requestDisLikeRemedy(Long.valueOf(remedy.getCodBarraEan()))
                    .observeOn(AndroidSchedulers.mainThread())
                    .onErrorReturn(throwable -> null)
                    .subscribe(responseBodyResponse -> {
                        mRemedyProgress.setVisibility(View.GONE);
                        if (responseBodyResponse != null && responseBodyResponse.isSuccessful()) {
                            isLiked = false;
                            mInteractor.removeDislikedContentCode();
                            bottomViews.likeImage.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_like_empty));
                        } else {
                            mView.showToast(mContext.getString(R.string.http_error_generic));
                        }
                    }));
        } else {
            requestLikeRemedies(Long.valueOf(remedy.getCodBarraEan()), bottomViews.likeImage);
        }
    });

    bottomSheetDialog.setContentView(dialogView);
    bottomSheetDialog.getWindow().findViewById(R.id.design_bottom_sheet)
            .setBackgroundResource(R.color.default_dialog_background);

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

    BottomSheetBehavior mBehavior = BottomSheetBehavior.from((View) dialogView.getParent());
    mBehavior.setPeekHeight(mView.getRootHeight() - 200);

    bottomSheetDialog.setOnDismissListener(dialog -> {
        if (mInteractor.getLikedRemedyCount() < mAdapterCountAfterFetching) {
            requestFavRemedies();
        }
    });

    bottomSheetDialog.show();
}