package com.ardraw.ardrawingflow.data.repository;

import androidx.lifecycle.LiveData;

import com.ardraw.ardrawingflow.data.database.dao.FlowDataDao;
import com.ardraw.ardrawingflow.data.database.entity.FlowData;

import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class FlowRepository {
    private final FlowDataDao flowDataDao;
    private final ExecutorService executorService;

    public FlowRepository(FlowDataDao flowDataDao) {
        this.flowDataDao = flowDataDao;
        this.executorService = Executors.newSingleThreadExecutor();
    }

    public void insertAll(List<FlowData> flowDataList) {
        executorService.execute(() -> flowDataDao.insertAll(flowDataList));
    }

    public void insert(FlowData flowData) {
        executorService.execute(() -> flowDataDao.insert(flowData));
    }

    public void delete(FlowData flowData) {
        executorService.execute(() -> flowDataDao.delete(flowData));
    }

    public LiveData<List<FlowData>> getLike() {
        return flowDataDao.getLike();
    }

    public LiveData<List<FlowData>> getDataByName(String name) {
        return flowDataDao.getDataByName(name);
    }

    public LiveData<List<FlowData>> getMinId() {
        return flowDataDao.getMinId();
    }

    public LiveData<List<FlowData>> getAddLiveData() {
        return flowDataDao.getAddLiveData();
    }

    public List<FlowData> getAdd() {
        return flowDataDao.getAdd();
    }

}
