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

The following examples show how to use android.support.design.widget.BottomSheetDialog#show() . 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: 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 2
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 3
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 4
Source File: WalletsActivity.java    From ETHWallet with GNU General Public License v3.0 5 votes vote down vote up
private void onAddWallet() {
    AddWalletView addWalletView = new AddWalletView(this);
    addWalletView.setOnNewWalletClickListener(this);
    addWalletView.setOnImportWalletClickListener(this);
    dialog = new BottomSheetDialog(this);
    dialog.setContentView(addWalletView);
    dialog.setCancelable(true);
    dialog.setCanceledOnTouchOutside(true);
    dialog.show();
}
 
Example 5
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 6
Source File: GankViewActivity.java    From FlipGank with Apache License 2.0 5 votes vote down vote up
@OnClick(R.id.more)
void showMore(View view) {
    BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this);
    GankBottom gankBottom = (GankBottom) LayoutInflater.from(this).inflate(R.layout.bottom_sheet, null, false);
    gankBottom.bind(mGankItem, null);
    bottomSheetDialog.setContentView( gankBottom);
    bottomSheetDialog.show();
}
 
Example 7
Source File: GankAdapter.java    From FlipGank with Apache License 2.0 5 votes vote down vote up
@Override
public void showBottomSheet(GankItem gankItem) {
    BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(mContext);
    GankItemView gankItemView = (GankItemView) LayoutInflater.from(mContext).inflate(R.layout.bottom_sheet, null, false);
    gankItemView.bind(gankItem, GankAdapter.this);
    bottomSheetDialog.setContentView((View) gankItemView);
    bottomSheetDialog.show();
}
 
Example 8
Source File: TagSettings.java    From com.ruuvi.station with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void showImageSourceSheet() {
    final BottomSheetDialog sheetDialog = new BottomSheetDialog(this);
    ListView listView = new ListView(this);
    String[] menu = {
            getResources().getString(R.string.camera),
            getResources().getString(R.string.gallery)
    };

    listView.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, menu));
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            switch (position) {
                case 0:
                    dispatchTakePictureIntent();
                    break;
                case 1:
                    getImageFromGallery();
                    break;
            }
            sheetDialog.dismiss();
        }
    });

    sheetDialog.setContentView(listView);
    sheetDialog.show();
}
 
Example 9
Source File: WalletsActivity.java    From trust-wallet-android-source with GNU General Public License v3.0 5 votes vote down vote up
private void onAddWallet() {
	AddWalletView addWalletView = new AddWalletView(this);
	addWalletView.setOnNewWalletClickListener(this);
	addWalletView.setOnImportWalletClickListener(this);
	dialog = new BottomSheetDialog(this);
	dialog.setContentView(addWalletView);
	dialog.setCancelable(true);
	dialog.setCanceledOnTouchOutside(true);
	dialog.show();
}
 
Example 10
Source File: TransactionsActivity.java    From trust-wallet-android-source with GNU General Public License v3.0 5 votes vote down vote up
private void openExchangeDialog() {
    Wallet wallet = viewModel.defaultWallet().getValue();
    if (wallet == null) {
        Toast.makeText(this, getString(R.string.error_wallet_not_selected), Toast.LENGTH_SHORT)
                .show();
    } else {
        BottomSheetDialog dialog = new BottomSheetDialog(this);
        DepositView view = new DepositView(this, wallet);
        view.setOnDepositClickListener(this::onDepositClick);
        dialog.setContentView(view);
        dialog.show();
        this.dialog = dialog;
    }
}
 
Example 11
Source File: HomeActivity.java    From alpha-wallet-android with MIT License 5 votes vote down vote up
private void openExchangeDialog() {
    Wallet wallet = ((WalletFragment)walletFragment).getCurrentWallet();
    if (wallet == null) {
        Toast.makeText(this, getString(R.string.error_wallet_not_selected), Toast.LENGTH_SHORT)
                .show();
    } else {
        BottomSheetDialog dialog = new BottomSheetDialog(this);
        DepositView view = new DepositView(this, wallet);
        view.setOnDepositClickListener(this::onDepositClick);
        dialog.setContentView(view);
        dialog.show();
        this.dialog = dialog;
    }
}
 
Example 12
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 13
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 14
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 15
Source File: MainActivity.java    From AndroidTopSheet with Apache License 2.0 4 votes vote down vote up
public void openBottomSheetDialog(View view) {
    BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this);
    bottomSheetDialog.setContentView(R.layout.sheet_content);
    bottomSheetDialog.show();
}
 
Example 16
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();
}
 
Example 17
Source File: MainActivity.java    From Memory-capsule with Apache License 2.0 4 votes vote down vote up
private void initEditpassworddialog(){//实例化一个重新编辑密码的dialog
    if (!password.isEmpty()){
        password="";
    }
    final BottomSheetDialog passwordbottomsheetdialog=new BottomSheetDialog(MainActivity.this);
    View dialogview=LayoutInflater.from(MainActivity.this)
            .inflate(R.layout.sheetdialog_password,null);
    final KeynumberDialog keynumberDialog=(KeynumberDialog)dialogview.findViewById(R.id.main_sheetdialog_keynumber);
    final KeyPasswordView keyPasswordView=(KeyPasswordView)dialogview.findViewById(R.id.main_sheetdialog_passwordview);
    keyPasswordView.setRouldRectcolor(maincolor);
    keynumberDialog.setOnNumberClickListener(new KeynumberDialog.OnNumberClickListener() {
        @Override
        public void onNumberReturn(String number) {
            password+=number;
            if (password.length()==6){
                if (prestenerImpMain.iscurrentthepasswordfromSeting(password)){
                    startListSecretActivity();
                    password="";
                    passwordbottomsheetdialog.dismiss();
                }else {
                    Toast.makeText(MainActivity.this, "输入密码有误", Toast.LENGTH_SHORT).show();
                    password="";
                }
            }
            keyPasswordView.changeTheNum(password.length());
        }

        @Override
        public void onNumberDelete() {
            if (password.length()<=1){
                password="";
            }else {
                password=password.substring(0,password.length()-1);
            }
            keyPasswordView.changeTheNum(password.length());
        }
    });
    passwordbottomsheetdialog.setContentView(dialogview);
    passwordbottomsheetdialog.show();

}
 
Example 18
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 19
Source File: RemedyPresenterImpl.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);
    }

    if (mInteractor.isRemedyLiked(Long.valueOf(remedy.getCodBarraEan()))) {
        bottomViews.likeImage.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_like_filled));
    }

    bottomViews.likeImage.setOnClickListener(v -> {
        mRemedyProgress.setVisibility(View.VISIBLE);
        if (mInteractor.isRemedyLiked(Long.valueOf(remedy.getCodBarraEan()))) {
            Timber.i("Already liked");
            mSubscription.add(mInteractor.requestDisLikeRemedy(Long.valueOf(remedy.getCodBarraEan()))
                    .observeOn(AndroidSchedulers.mainThread())
                    .onErrorReturn(throwable -> null)
                    .subscribe(responseBodyResponse -> {
                        mRemedyProgress.setVisibility(View.GONE);
                        mInteractor.removeRemedyFromLikedList(Long.valueOf(remedy.getCodBarraEan()));
                        if (responseBodyResponse != null && responseBodyResponse.isSuccessful()) {
                            isLiked = false;
                            bottomViews.likeImage.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_like_empty));
                        } else {
                            mView.showToast(mContext.getString(R.string.http_error_generic));
                        }
                    }));
        } else {
            Timber.i("Not Liked yet");
            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.show();
}
 
Example 20
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();
}