Java Code Examples for com.afollestad.materialdialogs.MaterialDialog#dismiss()

The following examples show how to use com.afollestad.materialdialogs.MaterialDialog#dismiss() . 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: CGroupsFragment.java    From call_manage with MIT License 6 votes vote down vote up
@Override
public void onImport(CGroup list, File excelFile, int nameColIndex, int numberColIndex) {
    MaterialDialog progressDialog = new MaterialDialog.Builder(getContext())
            .progress(false, 0, true)
            .progressNumberFormat("%1d/%2d")
            .show();

    AsyncSpreadsheetImport task = new AsyncSpreadsheetImport(getContext(),
            excelFile,
            nameColIndex,
            numberColIndex,
            list);

    AsyncSpreadsheetImport.OnProgressListener onProgressListener = (rowsRead, rowsCount) -> {
        progressDialog.setProgress(rowsRead);
        progressDialog.setMaxProgress(rowsCount);
    };

    AsyncSpreadsheetImport.OnFinishListener onFinishListener = callback -> progressDialog.dismiss();

    task.setOnProgressListener(onProgressListener);
    task.setOnFinishListener(onFinishListener);
    task.execute();
}
 
Example 2
Source File: MainActivity.java    From Elephant with Apache License 2.0 6 votes vote down vote up
/**
 * 退出登录 dialog 按钮点击监听事件
 * @param dialog
 * @param which
 */
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
    switch (which) {
        case POSITIVE:
            if (getUserConstant().logout()) { //退出登录
                mLoginShowRl.setVisibility(View.GONE);
                mLoginTv.setVisibility(View.VISIBLE);
                mMainMenuList.removeAll(mMyMenuList);
                mMenuAdapter.notifyDataSetChanged();
                mUserImgIv.setImageURI(Uri.parse("res://com.jun.elephant/" + R.color.main_bg));
                dialog.dismiss();
            }
            break;
        case NEGATIVE:
            dialog.dismiss();
            break;
    }
}
 
Example 3
Source File: MainActivity.java    From SafelyAndroid with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    new ConfirmDialogFragment().show(getSupportFragmentManager(), "ConfirmDialogFragment");
    Observable.timer(2, TimeUnit.SECONDS)
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Action1<Long>() {
                @Override
                public void call(Long aLong) {
                    safeCommit(SupportFragmentTransactionBuilder.transaction(
                            getSupportFragmentManager())
                            .add(R.id.mHeader, new HeaderFragment(), "HeaderFragment")
                            .add(R.id.mBody, new BodyFragment(), "BodyFragment")
                            .add(R.id.mFooter, new FooterFragment(), "FooterFragment")
                            .build());
                }
            }, new Action1<Throwable>() {
                @Override
                public void call(Throwable throwable) {
                    throwable.printStackTrace();
                }
            });

    try {
        safeCommit(SupportFragmentTransactionBuilder.transaction(getSupportFragmentManager())
                .remove("HeaderFragment")
                .build());
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }

    MaterialDialog dialog = new MaterialDialog.Builder(this).content("Test for dismiss").show();
    dialog.dismiss();
}
 
Example 4
Source File: FindKeywordsDialog.java    From 920-text-editor-v2 with Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
    switch (which) {
        case NEGATIVE:
            DBHelper.getInstance(context).clearFindKeywords(isReplace);
        default:
            dialog.dismiss();
            break;
    }
}
 
Example 5
Source File: RecentFilesManager.java    From 920-text-editor-v2 with Apache License 2.0 5 votes vote down vote up
@Override
public void onSelection(MaterialDialog materialDialog, View view, int i, CharSequence charSequence) {
    materialDialog.dismiss();
    if(onFileItemClickListener == null)
        return;
    DBHelper.RecentFileItem item = list.get(i);
    onFileItemClickListener.onClick(item);
}
 
Example 6
Source File: SettingActivity.java    From Elephant with Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
    switch (which) {
        case POSITIVE:
            cleanCache();
            break;
        case NEGATIVE:
            dialog.dismiss();
            break;
    }
}
 
Example 7
Source File: UtilsHelper.java    From WhatsAppBetaUpdater with GNU General Public License v3.0 5 votes vote down vote up
public static void dismissDialog(MaterialDialog dialog) {
    if (dialog.isShowing()) { // Check if the dialog is showing
        // Get the Context that was used for the dialog
        Context context = ((ContextWrapper) dialog.getContext()).getBaseContext();

        // If the Context was an Activity AND it hasn't been finished
        if (context instanceof Activity) {
            if (!((Activity)context).isFinishing()) {
                dialog.dismiss();
            }
        } else {
            dialog.dismiss();
        }
    }
}
 
Example 8
Source File: FindKeywordsDialog.java    From 920-text-editor-v2 with Apache License 2.0 4 votes vote down vote up
@Override
public void onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) {
    dialog.dismiss();
    editText.setText(text.toString());
}
 
Example 9
Source File: ShareHelper.java    From AnimeTaste with MIT License 4 votes vote down vote up
private static void shareAction(Context context, MaterialDialog dialog) {
    dialog.dismiss();
    Toast.makeText(context, "感谢分享哟!", Toast.LENGTH_SHORT).show();
}