package com.ardraw.ardrawinggallery.util;

import android.content.Context;

import androidx.lifecycle.LiveData;

import com.ardraw.ardrawinggallery.room.AppDatabase;
import com.ardraw.ardrawinggallery.room.ArData;
import com.ardraw.ardrawinggallery.room.ArDataDao;

import java.util.List;

public class DatabaseUtil {
    public static final String DATABASE_NAME = "Room";
    public static final int DATABASE_VERSION = 1;

    private final ArDataDao arDataDao;

    public DatabaseUtil(Context context) {
        AppDatabase appDatabase = AppDatabase.getInstance(context);
        arDataDao = appDatabase.arDataDao();
    }

    public void insertAll(List<ArData> arDataList) {
        new Thread(() -> arDataDao.insertAll(arDataList)).start();
    }

    public LiveData<List<ArData>> getAllFavorite() {
        return arDataDao.getAllFavorite();
    }

    public LiveData<List<ArData>> getListByName(String name) {
        return arDataDao.getListByName(name);
    }

    public LiveData<List<ArData>> getFirst() {
        return arDataDao.getFirst();
    }

    public LiveData<List<ArData>> getAllImportLive() {
        return arDataDao.getAllImportLive();
    }

    public void insert(ArData arData) {
        arDataDao.insert(arData);
    }

    public List<ArData> getAllImport() {
        return arDataDao.getAllImport();
    }
}
