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 DialogProgress {
    private TextView textView;
    private AlertDialog alertDialog;

    public static DialogProgress showDialog(final Activity activity) {
        return showDialog(activity, true);
    }
    public static DialogProgress showDialog(Activity activity, boolean cancelable) {
        DialogProgress dialogShowLoading= new DialogProgress();
        View view = View.inflate(activity, R.layout.dialog_progress, null);
        TextView dialog_loading = view.findViewById(R.id.dialog_progress);
        AlertDialog mAlertDialog = new AlertDialog.Builder(activity, R.style.MyDialogActivityTheme)
                .setView(view)
                .create();
        mAlertDialog.setCancelable(cancelable);
        dialogShowLoading.setAlertDialog(mAlertDialog);
        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;
    }
}
