package com.ysnows.base.dialog;


import android.annotation.SuppressLint;
import android.content.Context;

import com.qmuiteam.qmui.widget.dialog.QMUITipDialog;
import com.ysnows.base.R;


/**
 * 就是自定义的Dialog,不可back或点击外部销
 */
public class QMUIProgressDialog {
    private QMUITipDialog tipDialog;

    /**
     * 展示正在加载对话框
     *
     * @param context
     *
     * @return
     */
    public QMUITipDialog show(Context context) {
        return show(context, context.getString(R.string.please_wait_for_a_while));
    }

    public QMUITipDialog show(Context context, int ResId) {
        return show(context, context.getString(ResId));
    }

    /**
     * 展示正在加载对话框
     *
     * @param context
     *
     * @return
     */
    @SuppressLint("CheckResult")
    public QMUITipDialog show(Context context, String tip) {
        if (context == null) {
            return null;
        }

        tipDialog = new QMUITipDialog.Builder(context)
                .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING)
                .setTipWord(tip)
                .create();
        tipDialog.show();
        return tipDialog;
    }


    /**
     * 隐藏ProgressDialog
     */
    public void dismiss() {

        if (tipDialog != null) {
            tipDialog.dismiss();
            tipDialog = null;
        }
    }


}
