Java 类com.afollestad.materialdialogs.GravityEnum 实例源码

项目:GitHub    文件:MainActivity.java   
@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();
}
项目:GitHub    文件:DialogUtils.java   
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();
    }
}
项目:LiteReader    文件:LoadingView.java   
/**
 * 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();
    }
}
项目:myapplication    文件:FindGankAty.java   
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);
    }
}
项目:DialogAlchemy    文件:DialogExampleFragment.java   
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());
}
项目:Sleeply-Android    文件:MainActivity.java   
@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();
}
项目:FirstBuild-Mobile-Android-Old    文件:ParagonMainActivity.java   
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();
}
项目:Speculum-Android    文件:MainActivity.java   
@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();
}
项目:light-novel-library_Wenku8_Android    文件:FavFragment.java   
@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();
}
项目:light-novel-library_Wenku8_Android    文件:SearchActivity.java   
@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();
}
项目:material-dialogs    文件:MainActivity.java   
@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();
}
项目:material-dialogs    文件:MDRootLayout.java   
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;
    }
  }
}
项目:material-dialogs    文件:DialogUtils.java   
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();
  }
}
项目:GitHub    文件:MainActivity.java   
@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();
}
项目:GitHub    文件:MDRootLayout.java   
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;
        }
    }
}
项目:GitHub    文件:DialogUtils.java   
private static int gravityEnumToAttrInt(GravityEnum value) {
    switch (value) {
        case CENTER:
            return 1;
        case END:
            return 2;
        default:
            return 0;
    }
}
项目:RealmSample    文件:MdDialogFactory.java   
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
}
项目:GreenDaoSample    文件:MdDialogFactory.java   
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
}
项目:polar-dashboard    文件:ChangelogDialog.java   
@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();
}
项目:PxerStudio    文件:Tool.java   
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);
}
项目:PxerStudio    文件:Tool.java   
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);
}
项目:PxerStudio    文件:ExportingUtils.java   
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();
}
项目:EasyFrame    文件:MDRootLayout.java   
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;
        }
    }
}
项目:EasyFrame    文件:DialogUtils.java   
private static int gravityEnumToAttrInt(GravityEnum value) {
    switch (value) {
        case CENTER:
            return 1;
        case END:
            return 2;
        default:
            return 0;
    }
}
项目:EasyFrame    文件:DialogUtils.java   
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();
    }
}
项目:seglio    文件:AboutActivity.java   
void showTC()
{
    new MaterialDialog.Builder(getActivity())
            .title("Terms & Conditions")
            .content(R.string.tc)
            .positiveText("Dismiss")
            .contentGravity(GravityEnum.CENTER)
            .show();
}
项目:seglio    文件:AboutActivity.java   
void showSP()
{
    new MaterialDialog.Builder(getActivity())
            .title("Safety Guidelines")
            .content(R.string.sp)
            .contentGravity(GravityEnum.CENTER)
            .positiveText("Dismiss")
            .show();
}
项目:seglio    文件:LoginActivity.java   
void showTC()
{
    new MaterialDialog.Builder(this)
            .title("Terms & Conditions")
            .content(R.string.tc)
            .positiveText("Dismiss")
            .contentGravity(GravityEnum.CENTER)
            .show();
}
项目:Hentoid    文件:ImportActivity.java   
@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();
}
项目:material-dialogs    文件:MainActivity.java   
@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();
}
项目:material-dialogs    文件:MDRootLayout.java   
public void setButtonStackedGravity(GravityEnum gravity) {
  for (MDButton mButton : buttons) {
    if (mButton != null) {
      mButton.setStackedGravity(gravity);
    }
  }
}
项目:material-dialogs    文件:DialogUtils.java   
private static int gravityEnumToAttrInt(GravityEnum value) {
  switch (value) {
    case CENTER:
      return 1;
    case END:
      return 2;
    default:
      return 0;
  }
}
项目:GitHub    文件:MDButton.java   
private void init(Context context) {
    stackedEndPadding = context.getResources()
            .getDimensionPixelSize(R.dimen.md_dialog_frame_margin);
    stackedGravity = GravityEnum.END;
}
项目:GitHub    文件:MDButton.java   
public void setStackedGravity(GravityEnum gravity) {
    stackedGravity = gravity;
}
项目:GitHub    文件:MDRootLayout.java   
public void setButtonGravity(GravityEnum gravity) {
    buttonGravity = gravity;
    invertGravityIfNecessary();
}
项目:GitHub    文件:MDRootLayout.java   
public void setButtonStackedGravity(GravityEnum gravity) {
    for (MDButton mButton : buttons) {
        if (mButton != null)
            mButton.setStackedGravity(gravity);
    }
}
项目:myapplication    文件:FindSearchAty.java   
@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;
    }
}
项目:Minerva    文件:LibraryFragment.java   
/**
 * 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();
}
项目:DialogAlchemy    文件:SorceryStone.java   
public GravityEnum getTitleGravity() {
    return titleGravity;
}
项目:DialogAlchemy    文件:SorceryStone.java   
public GravityEnum getContentGravity() {
    return contentGravity;
}