package xn.xxp.receiver;

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

import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.ThreadUtils;

import xn.xxp.app.SyncFaceTool;
import xn.xxp.room.RoomTool;
import xn.xxp.utils.Tool;

public class TimeTickReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        // 保活用
        Intent newIntent = new Intent("XN_ACTION");
        intent.putExtra("heartbeat", "heartbeat");
        context.sendBroadcast(newIntent);
        Tool.INSTANCE.startTaskService();
        ThreadUtils.executeByCached(new ThreadUtils.SimpleTask<Object>() {
            @Override
            public Object doInBackground() throws Throwable {
                SyncFaceTool.INSTANCE.doWork();
                return null;
            }

            @Override
            public void onSuccess(Object result) {
                LogUtils.json(RoomTool.getInstance().faceDao().getAll());
            }
        });
    }
}
