package com.oo.seex.sys_state.state;

import android.content.Context;
import android.content.Intent;

import com.oo.seex.sys_state.Config;
import com.oo.seex.sys_state.Register;
import com.oo.seex.sys_state.state.bean.TimeState;

/**
 * Created by gyp on 17/7/5.
 */

public class TimeTickReceiver extends BaseReceiver {

    public TimeTickReceiver(Context context, Register register) {
        super(context, register);
        addAction(Intent.ACTION_TIME_TICK);
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        if(intent.ACTION_TIME_TICK.equals(intent.getAction())){
            TimeState state = new TimeState();
            state.setTime(System.currentTimeMillis());
            register.callback(Config.FLAG_TIME_STATE,state);
        }
    }

    @Override
    public void regist() {
        super.regist();
        //初始化时拿一下当前时间
        TimeState state = new TimeState();
        state.setTime(System.currentTimeMillis());
        register.callback(Config.FLAG_TIME_STATE,state);
    }
}
