package xn.hxp.receiver;

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

import com.blankj.utilcode.util.TimeUtils;

import org.greenrobot.eventbus.EventBus;

import java.text.SimpleDateFormat;
import java.util.Locale;

import xn.hxp.event.UpdateTimeEvent;

/**
 * 分钟广播
 */
public class MinuteTickReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction() != null && intent.getAction().equals(Intent.ACTION_TIME_TICK)) {
            String nowString = TimeUtils.getNowString(new SimpleDateFormat("M月d日  EEEE  HH:mm", Locale.getDefault()));
            EventBus.getDefault().post(new UpdateTimeEvent(nowString));
        }
    }
}
