package com.casic.dcms.utils;

import android.app.Activity;
import android.content.Context;
import android.view.WindowManager;

import com.qmuiteam.qmui.widget.dialog.QMUITipDialog;

public class DialogHelper {
    private static QMUITipDialog loadingDialog;

    public static void showLoadingDialog(Context context, String message) {
        loadingDialog = new QMUITipDialog.Builder(context)
                .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING)
                .setTipWord(message)
                .create();
        if (!((Activity) context).isDestroyed()) {
            try {
                loadingDialog.show();
            } catch (WindowManager.BadTokenException e) {
                e.printStackTrace();
            }
        }
    }

    public static void dismissLoadingDialog() {
        if (loadingDialog.isShowing()) {
            loadingDialog.dismiss();
        }
    }
}
