package com.sheep.gamegroup.view.dialog;

import android.app.Activity;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.widget.TextView;

import com.sheep.jiuyan.samllsheep.R;

/**
 * 用于加载中对话框
 * Created by realicing on 2018/08/09.
 * realicing@sina.com
 */
public class DialogLoading {
    private TextView textView;
    private AlertDialog alertDialog;

    public static DialogLoading showDialog(final Activity activity) {
        return showDialog(activity, true);
    }
    public static DialogLoading showDialog(Activity activity, boolean cancelable) {
        DialogLoading dialogShowLoading= new DialogLoading();
        View view = View.inflate(activity, R.layout.dialog_loading, null);
        TextView dialog_loading = view.findViewById(R.id.dialog_loading);
        AlertDialog mAlertDialog = new AlertDialog.Builder(activity, R.style.MyDialogActivityTheme)
                .setView(view)
                .create();
        dialogShowLoading.setAlertDialog(mAlertDialog);
        mAlertDialog.setCancelable(cancelable);
        try {
            mAlertDialog.show();
        } catch (Exception e) {
            e.printStackTrace();
        }
        dialogShowLoading.setTextView(dialog_loading);
        return dialogShowLoading;
    }

    public TextView getTextView() {
        return textView;
    }

    public void setTextView(TextView textView) {
        this.textView = textView;
    }

    public AlertDialog getAlertDialog() {
        return alertDialog;
    }

    public void setAlertDialog(AlertDialog alertDialog) {
        this.alertDialog = alertDialog;
    }
}
