package com.uas.module.common.task;

import android.os.Handler;
import android.os.Message;
import android.util.Log;

/**
 * Created by Arison on 2019/3/27.
 */
public class GlobalHandler extends Handler {
    
    private HandleMsgListener listener;
    private String Tag = GlobalHandler.class.getSimpleName();
    
    public interface HandleMsgListener{
        void handleMsg(Message msg);
    }

    private static class Holder{
        private static final GlobalHandler HANDLER = new GlobalHandler();
    }

    public static GlobalHandler getInstance(){
        return Holder.HANDLER;
    }


    @Override
    public void handleMessage(Message msg) {
        if (getHandleMsgListener() != null){
            getHandleMsgListener().handleMsg(msg);
        }else {
            Log.e(Tag,"请传入HandleMsgListener对象");
        }
        
    }

    public void setHandleMsgListener(HandleMsgListener listener){
        this.listener = listener;
    }

    public HandleMsgListener getHandleMsgListener(){
        return listener;
    }


}
