package com.auto.clicker.autoclicker.room.repository;

import android.app.Application;

import com.auto.clicker.autoclicker.room.AppDatabase;
import com.auto.clicker.autoclicker.room.TouchEventDao;
import com.auto.clicker.autoclicker.room.TouchEventEntity;

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

public class TouchEventRepository {
    private final TouchEventDao dao;
    private final ExecutorService executorService;

    public TouchEventRepository(Application application) {
        AppDatabase db = AppDatabase.getInstance(application);
        this.dao = db.touchEventDao();
        this.executorService = Executors.newSingleThreadExecutor();
    }

    public void insertEvent(TouchEventEntity touchEventEntity){
        executorService.execute(() -> dao.insertEvent(touchEventEntity));
    }

    public void deleteEvent(TouchEventEntity touchEventEntity){
        executorService.execute(() -> dao.deleteEvent(touchEventEntity));
    }

    public void updateEvent(TouchEventEntity touchEventEntity){
        executorService.execute(() -> dao.updateEvent(touchEventEntity));
    }

}
