package com.tjzhxx.union.system;/**
 * Created by Administrator on 2016/4/29.
 */

import android.content.Context;


/**
 * 描述:加载等待视图
 * @author yanghuaxiong
 * @create 2018/5/8 下午2:35
 *
 */
public class HodingView {
    private static HodingView mHodingView;
    private Context activityContext;
    public HodingViewDialog hodingViewDialog;
    private String message;

    //不允许被直接实例化
    protected HodingView() {
    }

    //HodingView的访问实例
    public static HodingView build() {
        if (mHodingView == null) {
            mHodingView = new HodingView();
        }
        return mHodingView;
    }

    public HodingView setContext(Context context) {
        this.activityContext = context;
        return mHodingView;
    }

    public void show() {
        message="";
        hide();
        if (hodingViewDialog == null) {
            hodingViewDialog = new HodingViewDialog(activityContext,message);
        }
        if (!hodingViewDialog.isShowing()) {
            hodingViewDialog.setMessage(message);
            hodingViewDialog.show();
        }
    }
    public void show(String msg) {
        message=msg;
        hide();
        if (hodingViewDialog == null) {
            hodingViewDialog = new HodingViewDialog(activityContext,message);
        }
        if (!hodingViewDialog.isShowing()) {
            hodingViewDialog.setMessage(message);
            hodingViewDialog.show();
        }
    }

    public void hide() {
        if (hodingViewDialog != null) {
            try {
                hodingViewDialog.dismiss();
            } catch (Exception e) {

            }
            hodingViewDialog = null;
        }
    }
}
