package com.android.chmo.ui.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.TextView;

import com.android.chmo.R;

/**
 * Created by Administrator on 2018/7/31.
 */

public class LoadingDialog extends Dialog {
    private TextView loadingText;
    private String loading;

    public LoadingDialog(Context context) {
        super(context,R.style.DialogStyle);
        setCanceledOnTouchOutside(true);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_loading);

        loadingText = (TextView) findViewById(R.id.loading);
        if(!TextUtils.isEmpty(loading)) {
            loadingText.setText(loading);
        }
    }

    public void setLoading(String text){
        loading = text;
        if(null != loadingText && !TextUtils.isEmpty(loading)) {
            loadingText.setText(loading);
        }
    }

    @Override
    public void dismiss() {
        loading = null;
        super.dismiss();
    }
}
