DialogUtils.java package xhc.agrtecservice.utils;import android.content.Context;import com.afollestad.materialdialogs.MaterialDialog;import xhc.agrtecservice.R;/** * Created by zhhaitong on 2016/7/8 0008 13:48. */public class DialogUtils {
package xhc.agrtecservice.utils; import android.content.Context; import com.afollestad.materialdialogs.MaterialDialog; import xhc.agrtecservice.R; /** * Created by zhhaitong on 2016/7/8 0008 13:48. */ public class DialogUtils { public static MaterialDialog.Builder getBaseDialogBuilder(Context context, String title, String content) { return new MaterialDialog.Builder(context) .title(title) .maxIconSize(60) .negativeColorRes(R.color.dialog_green) .positiveColorRes(R.color.dialog_green) .dividerColorRes(R.color.dialog_green) .widgetColorRes(R.color.dialog_green) .content(content); } public static MaterialDialog.Builder getBaseDialogBuilderWithLargerIcon(Context context, String title, String content) { return new MaterialDialog.Builder(context) .title(title) .maxIconSize(120) .negativeColorRes(R.color.dialog_green) .positiveColorRes(R.color.dialog_green) .dividerColorRes(R.color.dialog_green) .widgetColorRes(R.color.dialog_green) .content(content); } public static MaterialDialog showOKInfoDialog(Context context, String title, String content) { return getBaseDialogBuilder(context, title, content) .iconRes(R.drawable.icon_ok) .maxIconSize(60) .show(); } public static MaterialDialog showInfoDialog(Context context, String title, String content) { return getBaseDialogBuilder(context, title, content) .iconRes(R.drawable.icon_info) .maxIconSize(60) .show(); } public static MaterialDialog showWarningDialog(Context context, String title, String content) { return getBaseDialogBuilder(context, title, content) .iconRes(R.drawable.icon_warning) .maxIconSize(60) .show(); } public static MaterialDialog showErrorDialog(Context context, String title, String content) { return getBaseDialogBuilder(context, title, content) .iconRes(R.drawable.icon_error) .maxIconSize(60) .show(); } public static MaterialDialog showProgressDialog(Context context, String title, String content) { return new MaterialDialog.Builder(context) .title(title) .content(content) .progress(true, 0) .widgetColorRes(R.color.dialog_green) .canceledOnTouchOutside(false) .show(); } public static MaterialDialog showLodingDialog(Context context) { return new MaterialDialog.Builder(context) .content("正在加载数据...") .progress(true, 0) .widgetColorRes(R.color.dialog_green) .canceledOnTouchOutside(false) .show(); } public static MaterialDialog showAddingDialog(Context context) { return new MaterialDialog.Builder(context) .title("提示") .content("正在添加...") .progress(true, 0) .widgetColorRes(R.color.dialog_green) .canceledOnTouchOutside(false) .cancelable(false) .show(); } public static void closeDialog(MaterialDialog dialog) { if (dialog.isShowing()) { dialog.dismiss(); } } }