package com.oo.seex.sys_state.state;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.IntentFilter;

import com.oo.seex.sys_state.Register;

/**
 * Created by gyp on 17/7/4.
 */
 abstract class BaseReceiver extends BroadcastReceiver implements State{
    Context context;
    Register register;
    IntentFilter filter = new IntentFilter();
    public BaseReceiver(Context context, Register register){
        this.context = context;
        this.register = register;
    }
    protected  void addAction(String action){
        filter.addAction(action);
    }

    @Override
    public void unRegist() {
        if (context != null)
            context.unregisterReceiver(this);
    }

    @Override
    public void regist() {
        if(context!=null && filter != null)
            context.registerReceiver(this,filter);
    }
}
