@OnClick(R.id.themed) public void showThemed() { new MaterialDialog.Builder(this) .title(R.string.useGoogleLocationServices) .content(R.string.useGoogleLocationServicesPrompt) .positiveText(R.string.agree) .negativeText(R.string.disagree) .positiveColorRes(R.color.material_red_400) .negativeColorRes(R.color.material_red_400) .titleGravity(GravityEnum.CENTER) .titleColorRes(R.color.material_red_400) .contentColorRes(android.R.color.white) .backgroundColorRes(R.color.material_blue_grey_800) .dividerColorRes(R.color.accent) .btnSelector(R.drawable.md_btn_selector_custom, DialogAction.POSITIVE) .positiveColor(Color.WHITE) .negativeColorAttr(android.R.attr.textColorSecondaryInverse) .theme(Theme.DARK) .show(); }
public static GravityEnum resolveGravityEnum(Context context, @AttrRes int attr, GravityEnum defaultGravity) { TypedArray a = context.getTheme().obtainStyledAttributes(new int[]{attr}); try { switch (a.getInt(0, gravityEnumToAttrInt(defaultGravity))) { case 1: return GravityEnum.CENTER; case 2: return GravityEnum.END; default: return GravityEnum.START; } } finally { a.recycle(); } }
/** * Show the loading dialog. * * @param context the context. * @param stringRes the resource id of the content. * @param cancelable whether this loading dialog is cancelable. */ public void showLoadingView(Context context, @StringRes int stringRes, boolean cancelable) { if (sMaterialDialog == null) { sMaterialDialog = new MaterialDialog.Builder(context) .progress(true, 0) .widgetColorRes(R.color.colorAccent) .content(stringRes) .backgroundColorRes(R.color.white) .contentGravity(GravityEnum.CENTER) .canceledOnTouchOutside(cancelable) .cancelable(cancelable) .build(); sMaterialDialog.show(); } else if (sMaterialDialog.isShowing()) { sMaterialDialog.setContent(stringRes); } else { sMaterialDialog.show(); } }
private void initView() { isConnect = SystemUtils.checkNetworkConnection(FindGankAty.this); mTitleBackIBtn = (ImageButton) findViewById(R.id.title_gank_back_ibtn); mGankClassBtn = (Button) findViewById(R.id.title_gank_class_tv); mRecyclerView = (RecyclerView) findViewById(R.id.find_gank_recyclerview); mMaterialDialog = new MaterialDialog.Builder(FindGankAty.this) .content("Please waiting...") .contentGravity(GravityEnum.CENTER) .progress(true, 0) .progressIndeterminateStyle(true) .show(); mMaterialDialog.setCancelable(false); if (isConnect) { switchSelectedDatas("all"); } else { mMaterialDialog.dismiss(); SystemUtils.noNetworkAlert(FindGankAty.this); } }
private void createSorceryDialog() { PhilosopherStone stone = new SorceryStone.Builder(getActivity()) .titleColor(Color.MAGENTA) .titleGravity(GravityEnum.CENTER) .contentColor(Color.CYAN) .contentGravity(GravityEnum.CENTER) .buttonRippleColor(Color.YELLOW) .contentLineSpacing(2.0f) .theme(Theme.DARK) .setPhilosopherStone(new ColorPaletteStone()) // special power .build(); Material.Builder builder = new Material.Builder(getActivity()) .setTitle("Sorcery Stone") .setNegativeButton(android.R.string.cancel, null) .setPositiveButton(android.R.string.ok, null) .setPhilosopherStone(stone); DialogAlchemy.show(getFragmentManager(), builder.build(), new MaterialDialogsTransmutationCircle()); }
@Override public void showStreamsDialog(List<Stream> streams) { MaterialDialog dialog = new MaterialDialog.Builder(this) .contentGravity(GravityEnum.CENTER) .customView(R.layout.dialog_sounds, false) .build(); RecyclerView grid = (RecyclerView) dialog.getCustomView(); if (grid != null) { grid.setLayoutManager(new GridLayoutManager(MainActivity.this, 2)); gridAdapter.setData(streams, (view, position, dataSet) -> { presenter.streamPicked(streams.get(position)); dialog.dismiss(); }); grid.setAdapter(gridAdapter); } dialog.show(); }
private void showOtaDialog() { dialogOtaProcessing = new MaterialDialog.Builder(this) .title(R.string.popup_ota_title) .content(R.string.popup_ota_content) .contentGravity(GravityEnum.CENTER) .progress(false, 100, true) .cancelable(false) .showListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialogInterface) { } }).build(); dialogOtaProcessing.show(); }
@Override public void showMap(String location) { String url = Constants.STATIC_MAPS_URL_FIRST + location + Constants.STATIC_MAPS_URL_SECOND + location + Constants.STATIC_MAPS_URL_THIRD + mapsApiKey; mapDialog = new MaterialDialog.Builder(this) .customView(R.layout.map_image, false) .contentGravity(GravityEnum.CENTER) .build(); View imageView = mapDialog.getCustomView(); Picasso.with(MainActivity.this).load(url).into((ImageView) imageView); mapDialog.show(); }
@Override public void onDeleteClick(View view, final int position) { // popup to show delete new MaterialDialog.Builder(getActivity()) .callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(MaterialDialog dialog) { super.onPositive(dialog); // delete operatio, delete from cloud first, if succeed then delete from local AsyncRemoveBookFromCloud arbfc = new AsyncRemoveBookFromCloud(); arbfc.execute(listNovelItemAid.get(position)); listNovelItemAid.remove(position); refreshList(timecount ++); } }) .theme(Theme.LIGHT) .content(R.string.dialog_content_want_to_delete) .contentGravity(GravityEnum.CENTER) .positiveText(R.string.dialog_positive_sure) .negativeText(R.string.dialog_negative_preferno) .show(); }
@Override public void onItemLongClick(View view, final int postion) { //Toast.makeText(this, postion + ": Long Click Detected", Toast.LENGTH_SHORT).show(); new MaterialDialog.Builder(this) .callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(MaterialDialog dialog) { super.onPositive(dialog); GlobalConfig.deleteSearchHistory(historyList.get(postion)); refreshHistoryList(); } }) .theme(Theme.LIGHT) .backgroundColorRes(R.color.dlgBackgroundColor) .contentColorRes(R.color.dlgContentColor) .positiveColorRes(R.color.dlgPositiveButtonColor) .negativeColorRes(R.color.dlgNegativeButtonColor) .title(getResources().getString(R.string.dialog_content_delete_one_search_record)) .content(historyList.get(postion)) .contentGravity(GravityEnum.CENTER) .positiveText(R.string.dialog_positive_likethis) .negativeText(R.string.dialog_negative_preferno) .show(); }
@OnClick(R.id.themed) public void showThemed() { new MaterialDialog.Builder(this) .title(R.string.useGoogleLocationServices) .content(R.string.useGoogleLocationServicesPrompt, true) .positiveText(R.string.agree) .negativeText(R.string.disagree) .positiveColorRes(R.color.material_red_400) .negativeColorRes(R.color.material_red_400) .titleGravity(GravityEnum.CENTER) .titleColorRes(R.color.material_red_400) .contentColorRes(android.R.color.white) .backgroundColorRes(R.color.material_blue_grey_800) .dividerColorRes(R.color.accent) .btnSelector(R.drawable.md_btn_selector_custom, DialogAction.POSITIVE) .positiveColor(Color.WHITE) .negativeColorAttr(android.R.attr.textColorSecondaryInverse) .theme(Theme.DARK) .show(); }
private void invertGravityIfNecessary() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { return; } Configuration config = getResources().getConfiguration(); if (config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) { switch (buttonGravity) { case START: buttonGravity = GravityEnum.END; break; case END: buttonGravity = GravityEnum.START; break; } } }
public static GravityEnum resolveGravityEnum( Context context, @AttrRes int attr, GravityEnum defaultGravity) { TypedArray a = context.getTheme().obtainStyledAttributes(new int[] {attr}); try { switch (a.getInt(0, gravityEnumToAttrInt(defaultGravity))) { case 1: return GravityEnum.CENTER; case 2: return GravityEnum.END; default: return GravityEnum.START; } } finally { a.recycle(); } }
@OnClick(R.id.stacked) public void showStacked() { new MaterialDialog.Builder(this) .title(R.string.useGoogleLocationServices) .content(R.string.useGoogleLocationServicesPrompt) .positiveText(R.string.speedBoost) .negativeText(R.string.noThanks) .btnStackedGravity(GravityEnum.END) .stackingBehavior(StackingBehavior.ALWAYS) // this generally should not be forced, but is used for demo purposes .show(); }
private void invertGravityIfNecessary() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) return; Configuration config = getResources().getConfiguration(); if (config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) { switch (buttonGravity) { case START: buttonGravity = GravityEnum.END; break; case END: buttonGravity = GravityEnum.START; break; } } }
private static int gravityEnumToAttrInt(GravityEnum value) { switch (value) { case CENTER: return 1; case END: return 2; default: return 0; } }
public static MaterialDialog showStacked(Context context, String title, String content, String positiveText, String negativeText) { return new MaterialDialog.Builder(context) .title(title) .content(content) .positiveText(positiveText) .negativeText(negativeText) .btnStackedGravity(GravityEnum.END) .forceStacking(true).build(); // context generally should not be forced, but is used for demo purposes }
@SuppressLint("InflateParams") @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { return new MaterialDialog.Builder(getActivity()) .title(R.string.changelog) .titleGravity(GravityEnum.CENTER) .titleColorAttr(R.attr.colorAccent) .adapter(new BulletPointListViewAdapter(getActivity(), R.array.changelog), null) .positiveText(R.string.cool) .build(); }
public static MaterialDialog.Builder prompt(Context c) { return new MaterialDialog.Builder(c) .negativeText(R.string.cancel) .titleGravity(GravityEnum.CENTER) .typeface(Tool.myType, Tool.myType) .positiveColor(Color.RED); }
public static MaterialDialog.Builder promptTextInput(Context c, String title) { return new MaterialDialog.Builder(c) .negativeText(R.string.cancel) .positiveText(R.string.ok) .title(title) .inputType(InputType.TYPE_CLASS_TEXT) .inputRange(0, 20) .titleGravity(GravityEnum.CENTER) .typeface(Tool.myType, Tool.myType) .positiveColor(Color.GREEN); }
public void showProgressDialog(Context context){ currentProgressDialog = new MaterialDialog.Builder(context) .titleGravity(GravityEnum.CENTER) .typeface(Tool.myType, Tool.myType) .cancelable(false) .canceledOnTouchOutside(false) .title("Painting...") .progress(true, 0) .progressIndeterminateStyle(true) .show(); }
private void invertGravityIfNecessary() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) return; Configuration config = getResources().getConfiguration(); if (config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) { switch (mButtonGravity) { case START: mButtonGravity = GravityEnum.END; break; case END: mButtonGravity = GravityEnum.START; break; } } }
void showTC() { new MaterialDialog.Builder(getActivity()) .title("Terms & Conditions") .content(R.string.tc) .positiveText("Dismiss") .contentGravity(GravityEnum.CENTER) .show(); }
void showSP() { new MaterialDialog.Builder(getActivity()) .title("Safety Guidelines") .content(R.string.sp) .contentGravity(GravityEnum.CENTER) .positiveText("Dismiss") .show(); }
void showTC() { new MaterialDialog.Builder(this) .title("Terms & Conditions") .content(R.string.tc) .positiveText("Dismiss") .contentGravity(GravityEnum.CENTER) .show(); }
@Override protected void onPreExecute() { super.onPreExecute(); final MaterialDialog mScanDialog = new MaterialDialog.Builder(ImportActivity.this) .title(R.string.import_dialog) .content(R.string.please_wait) .contentGravity(GravityEnum.CENTER) .progress(false, 100, false) .cancelable(false) .showListener(dialogInterface -> mImportDialog = (MaterialDialog) dialogInterface).build(); if (mScanDialog.getWindow() != null) { mScanDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); } downloadDirs = new ArrayList<>(); for (Site site : Site.values()) { // Grab all folders in site folders in storage directory downloadDirs.add(FileHelper.getSiteDownloadDir(ImportActivity.this, site)); } files = new ArrayList<>(); for (File downloadDir : downloadDirs) { // Grab all files in downloadDirs files.addAll(Arrays.asList(downloadDir.listFiles())); } mScanDialog.show(); }
@OnClick(R.id.stacked) public void showStacked() { new MaterialDialog.Builder(this) .title(R.string.useGoogleLocationServices) .content(R.string.useGoogleLocationServicesPrompt, true) .positiveText(R.string.speedBoost) .negativeText(R.string.noThanks) .btnStackedGravity(GravityEnum.END) .stackingBehavior( StackingBehavior .ALWAYS) // this generally should not be forced, but is used for demo purposes .show(); }
public void setButtonStackedGravity(GravityEnum gravity) { for (MDButton mButton : buttons) { if (mButton != null) { mButton.setStackedGravity(gravity); } } }
private void init(Context context) { stackedEndPadding = context.getResources() .getDimensionPixelSize(R.dimen.md_dialog_frame_margin); stackedGravity = GravityEnum.END; }
public void setStackedGravity(GravityEnum gravity) { stackedGravity = gravity; }
public void setButtonGravity(GravityEnum gravity) { buttonGravity = gravity; invertGravityIfNecessary(); }
public void setButtonStackedGravity(GravityEnum gravity) { for (MDButton mButton : buttons) { if (mButton != null) mButton.setStackedGravity(gravity); } }
@Override public void onClick(View view) { switch (view.getId()) { case R.id.find_search_back_ibtn: FindSearchAty.this.finish(); break; case R.id.find_search_ibtn: mSearchContentStr = mSearchContentEt.getText().toString().trim(); if (!mSearchContentStr.isEmpty()) { mMaterialDialog = new MaterialDialog.Builder(FindSearchAty.this) .content("Please waiting...") .contentGravity(GravityEnum.CENTER) .progress(true, 0) .progressIndeterminateStyle(true) .show(); mMaterialDialog.setCancelable(false); new Thread(new Runnable() { @Override public void run() { try { String gankDatasJsonStr = HttpUtil.getSearchJsonStr(mSearchContentStr); Log.d("FindSearchAty", gankDatasJsonStr); if (!gankDatasJsonStr.equals("")) { Message message = mHandler.obtainMessage(); message.obj = gankDatasJsonStr; mHandler.sendMessage(message); } else { Log.d("FindSearchAty", "出错"); mMaterialDialog.dismiss(); } } catch (UnsupportedEncodingException e) { Log.d("FindSearchAty", e.getMessage()); } } }).start(); } else { Toast.makeText(FindSearchAty.this, "请输入您的搜索内容 !!!", Toast.LENGTH_LONG).show(); } break; } }
/** * Show the view options dialog when the FAB is clicked. */ @OnClick(R.id.fab) void onFabClick() { // Inflate dialog view and get views. @SuppressLint("InflateParams") View view = LayoutInflater.from(getContext()).inflate(R.layout.library_view_opts, null); final RadioGroup rgSortType = ButterKnife.findById(view, R.id.rg_sort_type); final RadioGroup rgSortDir = ButterKnife.findById(view, R.id.rg_sort_dir); final RadioGroup rgCardType = ButterKnife.findById(view, R.id.rg_card_type); // Set up views. rgSortType.check(sortType.getResId()); rgSortDir.check(sortDir.getResId()); rgCardType.check(cardType.getResId()); // Construct material dialog. new MaterialDialog.Builder(getContext()) .title(R.string.action_view_opts) .titleGravity(GravityEnum.CENTER) .customView(view, true) .contentGravity(GravityEnum.CENTER) .positiveText(R.string.ok) .negativeText(R.string.cancel) .onPositive((dialog, which) -> { // Figure out which options are different. boolean sortTypeChanged = rgSortType.getCheckedRadioButtonId() != sortType.getResId(); boolean sortDirChanged = rgSortDir.getCheckedRadioButtonId() != sortDir.getResId(); boolean cardTypeChanged = rgCardType.getCheckedRadioButtonId() != cardType.getResId(); // Save new options locally if different, then persist them all to preferences. if (sortTypeChanged) sortType = SortType.fromResId(rgSortType.getCheckedRadioButtonId()); if (sortDirChanged) sortDir = SortDir.fromResId(rgSortDir.getCheckedRadioButtonId()); if (cardTypeChanged) cardType = BookCardType.fromResId(rgCardType.getCheckedRadioButtonId()); Minerva.prefs().putLibraryViewOpts(sortType, sortDir, cardType); // Re-sort data if necessary. if (sortTypeChanged || sortDirChanged) sortRealmResults(); // Switching the card type means switching the recycler view adapter, we certainly don't want to // do that if we haven't changed it. if (cardTypeChanged) changeCardType(); // We only need to explicitly tell the recycler view to redraw its items if we changed our sort // options and didn't change our card type (swapping adapters to change card types would force a // redraw anyway). if ((sortTypeChanged || sortDirChanged) && !cardTypeChanged) //noinspection unchecked adapter.updateRealmResults(books); }) .show(); }
public GravityEnum getTitleGravity() { return titleGravity; }
public GravityEnum getContentGravity() { return contentGravity; }