package com.zkjc.common.view;

import android.app.Dialog;
import android.content.Context;
import android.widget.TextView;

import com.zkjc.utils.R;


public class ProgressDialog {
    private Context context;

    public ProgressDialog(Context context) {
        this.context = context;
    }

    Dialog progressDialog = null;
    /**
     * 显示进度条
     *
     *
     * @param text
     */
    public void showProgressDialog( String text) {
        if (progressDialog == null) {
            progressDialog = new Dialog(context, R.style.progress_dialog);
        }
        progressDialog.setContentView(R.layout.dialog_layout);
        progressDialog.setCancelable(true);
        progressDialog.setOnCancelListener(dialogInterface -> {
            caneProgressDialog();
        });
        progressDialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
        TextView msg = (TextView) progressDialog.findViewById(R.id.id_tv_loadingmsg);
        msg.setText(text);
        progressDialog.show();
    }
    /**
     * 取消进度条
     *
     * @param
     * @param
     */
    public void caneProgressDialog() {
        if(progressDialog!=null)
            progressDialog.dismiss();
        progressDialog = null;
    }
}
