package com.unis.model.login_log;

import android.os.AsyncTask;

import com.unis.model.room.MyDB;
import com.xyxsbj.mylibrary.tool.LogTool;

import java.lang.ref.WeakReference;
import java.util.List;


/**
 * 获取登录记录
 * 创建人: mQ
 * 时间: 2021/2/7 15:59
 */
public class LoginLogListTask extends AsyncTask<Void, Void, List<LoginLog>> {

    private WeakReference<LoginLogsCallback> mCallback;

    public LoginLogListTask(LoginLogsCallback callback) {
        mCallback = new WeakReference<>(callback);
    }

    @Override
    protected List<LoginLog> doInBackground(Void... voids) {
        LogTool.i("获取登录记录");
        return MyDB.get().loginDao().getAll();
    }

    @Override
    protected void onPostExecute(List<LoginLog> list) {
        super.onPostExecute(list);
        LoginLogsCallback callback = this.mCallback.get();
        if (callback != null) {
            callback.onLoginLogsListener(list);
        }
    }


    public interface LoginLogsCallback {
        void onLoginLogsListener(List<LoginLog> list);
    }
}
