Java Code Examples for android.support.design.widget.BottomSheetBehavior#setPeekHeight()
The following examples show how to use
android.support.design.widget.BottomSheetBehavior#setPeekHeight() .
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 |
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: MainActivity.java From CircularReveal with MIT License | 6 votes |
@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 3
Source File: MoonDialog.java From SuntimesWidget with GNU General Public License v3.0 | 6 votes |
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 4
Source File: MyBottomSheetDialogFragment.java From AndroidDesignWidgetsSample with Apache License 2.0 | 6 votes |
@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 5
Source File: RegisterPresenterImpl.java From Saude-no-Mapa with MIT License | 6 votes |
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 6
Source File: LightMapDialog.java From SuntimesWidget with GNU General Public License v3.0 | 6 votes |
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 7
Source File: WorldMapDialog.java From SuntimesWidget with GNU General Public License v3.0 | 6 votes |
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 8
Source File: WorldMapDialog.java From SuntimesWidget with GNU General Public License v3.0 | 6 votes |
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 9
Source File: EditProfilePresenterImpl.java From Saude-no-Mapa with MIT License | 6 votes |
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 10
Source File: LoginPresenterImpl.java From Saude-no-Mapa with MIT License | 5 votes |
@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 11
Source File: HelpDialog.java From SuntimesWidget with GNU General Public License v3.0 | 5 votes |
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 12
Source File: RadialTransformationActivity.java From CircularReveal with MIT License | 4 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sample_2); ButterKnife.bind(this); Picasso.with(this) .load("http://camp-campbell.com/wp-content/uploads/2014/09/847187872-san-francisco.jpg") .resizeDimen(R.dimen.radial_card_width, R.dimen.radial_card_height) .centerCrop() .into(sanFranciscoView); videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { mp.setLooping(true); } }); videoView.setVideoURI(Uri.parse(VIDEO_URL)); videoView.start(); final GestureDetector detector = new GestureDetector(this, tapDetector); for (int i = 0; i < stack.getChildCount(); i++) { View view = stack.getChildAt(i); view.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return detector.onTouchEvent(event); } }); } final ViewRevealManager revealManager = new ViewRevealManager(); final SpringViewAnimatorManager springManager = new SpringViewAnimatorManager(); springManager.setDampingRatio(SpringForce.DAMPING_RATIO_NO_BOUNCY); springManager.setStiffness(SpringForce.STIFFNESS_LOW); stack.setViewRevealManager(revealManager); settingsView.addSwitch("Enable Spring", false, new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { stack.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 13
Source File: FavRemedyPresenterImpl.java From Saude-no-Mapa with MIT License | 4 votes |
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 14
Source File: FavEstablishmentPresenterImpl.java From Saude-no-Mapa with MIT License | 4 votes |
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: EmergencyPresenterImpl.java From Saude-no-Mapa with MIT License | 4 votes |
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 16
Source File: RemedyPresenterImpl.java From Saude-no-Mapa with MIT License | 4 votes |
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 17
Source File: EstablishmentPresenterImpl.java From Saude-no-Mapa with MIT License | 4 votes |
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 18
Source File: ReqMenuDialog.java From NanoIconPack with Apache License 2.0 | 4 votes |
@Override public void setupDialog(Dialog dialog, int style) { super.setupDialog(dialog, style); Bundle bundle = getArguments(); pos = bundle.getInt("pos"); bean = (AppBean) bundle.getSerializable("bean"); contentView = View.inflate(getContext(), R.layout.fragment_req_menu, null); dialog.setContentView(contentView); ((TextView) contentView.findViewById(R.id.tv_title)).setText(bean.getLabel()); if (bean.isMark()) { contentView.findViewById(R.id.view_menu_mark).setVisibility(View.GONE); contentView.findViewById(R.id.view_menu_undo_mark).setOnClickListener(this); contentView.findViewById(R.id.view_hint_undo_mark) .setVisibility(bean.isHintUndoMark() ? View.VISIBLE : View.GONE); } else { contentView.findViewById(R.id.view_menu_undo_mark).setVisibility(View.GONE); contentView.findViewById(R.id.view_menu_mark).setOnClickListener(this); contentView.findViewById(R.id.view_hint_mark) .setVisibility(bean.isHintMark() ? View.VISIBLE : View.GONE); } contentView.findViewById(R.id.view_hint_lost) .setVisibility(bean.isHintLost() ? View.VISIBLE : View.GONE); contentView.findViewById(R.id.view_menu_goto_market).setOnClickListener(this); contentView.findViewById(R.id.view_menu_copy_code).setOnClickListener(this); BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior .from((View) contentView.getParent()); if (bean.isHintLost()) { // In landscape, STATE_EXPANDED doesn't make sheet expanded. // Maybe it's a bug. So do this to fix it. if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { contentView.measure(0, 0); bottomSheetBehavior.setPeekHeight(contentView.getMeasuredHeight()); } bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED); } else { bottomSheetBehavior.setPeekHeight(getResources() .getDimensionPixelSize(R.dimen.req_bottom_menu_height)); } }
Example 19
Source File: SaleNHAssetActivity.java From AndroidWallet with GNU General Public License v3.0 | 4 votes |
@Override public void initViewObservable() { dialog = new BottomSheetDialog(this); DialogSaleNhassetConfirmLayoutBinding binding = DataBindingUtil.inflate(LayoutInflater.from(Utils.getContext()), R.layout.dialog_sale_nhasset_confirm_layout, null, false); dialog.setContentView(binding.getRoot()); 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); dialog.setCanceledOnTouchOutside(false); final SaleNhConfirmViewModel orderConfirmViewModel = new SaleNhConfirmViewModel(getApplication()); binding.setViewModel(orderConfirmViewModel); viewModel.uc.saleNHNBtnObservable.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() { @Override public void onPropertyChanged(Observable observable, int i) { try { if (TextUtils.isEmpty(viewModel.salePricesAmount.get())) { ToastUtils.showShort(R.string.module_mine_nh_asset_sale_price_hint); return; } if (TextUtils.isEmpty(viewModel.saleValidTime.get())) { ToastUtils.showShort(R.string.module_mine_nh_asset_sale_valid_time_hint); return; } if (TextUtils.equals(viewModel.saleValidTime.get(), "0")) { ToastUtils.showShort(R.string.module_mine_nh_asset_sale_valid_time_less_than_one); return; } if (Long.valueOf(Objects.requireNonNull(viewModel.saleValidTime.get())) > viewModel.saleValidTimeMax) { viewModel.saleValidTime.set(String.valueOf(viewModel.saleValidTimeMax)); return; } if (new BigDecimal(viewModel.salePricesAmount.get()).compareTo(BigDecimal.ZERO) < 0) { ToastUtils.showShort(R.string.module_mine_sale_nh_price_error); return; } SaleNHAssetParamsModel saleNHAssetParamsModel = new SaleNHAssetParamsModel(); saleNHAssetParamsModel.setNhAssetId(nhAssetModelBean.id); saleNHAssetParamsModel.setPriceAmount(viewModel.salePricesAmount.get()); saleNHAssetParamsModel.setPriceSymbol(viewModel.salePricesSymbol.get()); saleNHAssetParamsModel.setOrderMemo(viewModel.saleMemo.get()); saleNHAssetParamsModel.setValidTime(Long.parseLong(viewModel.saleValidTime.get())); orderConfirmViewModel.setSaleInfoData(saleNHAssetParamsModel); dialog.show(); } catch (Exception e) { } } }); viewModel.uc.choosePriceSymbolObservable.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() { @Override public void onPropertyChanged(Observable sender, int propertyId) { Bundle bundle = new Bundle(); bundle.putInt(IntentKeyGlobal.SALE_TO_SYMBOL_SELECT, IntentKeyGlobal.GET_CONTACT); ARouter.getInstance(). build(RouterActivityPath.ACTIVITY_SYMBOL_LIST). with(bundle). navigation(SaleNHAssetActivity.this, IntentKeyGlobal.REQ_SYMBOL_SELECT_CODE); } }); }
Example 20
Source File: InvokeTransferActivity.java From AndroidWallet with GNU General Public License v3.0 | 4 votes |
@Override public void initViewObservable() { dialog = new BottomSheetDialog(InvokeTransferActivity.this); DialogTransferPayConfirmBinding binding = DataBindingUtil.inflate(LayoutInflater.from(Utils.getContext()), R.layout.dialog_transfer_pay_confirm, null, false); dialog.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); dialog.setCanceledOnTouchOutside(false); final OrderConfirmViewModel orderConfirmViewModel = new OrderConfirmViewModel(getApplication()); binding.setViewModel(orderConfirmViewModel); viewModel.uc.invokeTransferConfirmObservable.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() { @Override public void onPropertyChanged(Observable observable, int i) { if (transferInvokeModel.getExpired() > 0 && System.currentTimeMillis() > transferInvokeModel.getExpired()) { finish(); IntentUtils.jumpToDappWithError(InvokeTransferActivity.this, baseInvokeModel, transferInvokeModel.getActionId(), "request expired!"); return; } if (TextUtils.isEmpty(transferInvokeModel.getFrom())) { finish(); IntentUtils.jumpToDappWithError(InvokeTransferActivity.this, baseInvokeModel, transferInvokeModel.getActionId(), Utils.getString(R.string.transferAccountName_empty)); return; } if (TextUtils.isEmpty(transferInvokeModel.getTo())) { finish(); IntentUtils.jumpToDappWithError(InvokeTransferActivity.this, baseInvokeModel, transferInvokeModel.getActionId(), Utils.getString(R.string.module_asset_receivablesAccountName_empty)); return; } if (TextUtils.isEmpty(String.valueOf(transferInvokeModel.getAmount()))) { finish(); IntentUtils.jumpToDappWithError(InvokeTransferActivity.this, baseInvokeModel, transferInvokeModel.getActionId(), Utils.getString(R.string.module_asset_transfer_amount_empty)); return; } if (TextUtils.equals(transferInvokeModel.getFrom(), transferInvokeModel.getTo())) { finish(); IntentUtils.jumpToDappWithError(InvokeTransferActivity.this, baseInvokeModel, transferInvokeModel.getActionId(), Utils.getString(R.string.module_asset_transfer_account_can_not_yourself)); return; } NumberFormat instance = NumberFormat.getInstance(); instance.setGroupingUsed(false); instance.setMaximumFractionDigits(transferInvokeModel.getPrecision()); TransferParamsModel transferParamsModel = new TransferParamsModel(); transferParamsModel.setAccountName(transferInvokeModel.getFrom()); transferParamsModel.setReceivablesAccountName(transferInvokeModel.getTo()); transferParamsModel.setTransferAmount(instance.format(transferInvokeModel.getAmount())); transferParamsModel.setTransferMemo(transferInvokeModel.getMemo()); transferParamsModel.setTransferSymbol(transferInvokeModel.getSymbol()); orderConfirmViewModel.setTransferInfoData(transferParamsModel); dialog.show(); } }); viewModel.uc.invokeTransferCancelObservable.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() { @Override public void onPropertyChanged(Observable sender, int propertyId) { finish(); IntentUtils.jumpToDappWithCancel(InvokeTransferActivity.this, baseInvokeModel, transferInvokeModel.getActionId()); } }); }