package com.prank.funnypranksounds.data.repository;

import android.content.Context;

import androidx.lifecycle.LiveData;

import com.prank.funnypranksounds.data.local.dao.AudioDataDao;
import com.prank.funnypranksounds.data.local.database.AppDatabase;
import com.prank.funnypranksounds.data.local.entity.AudioData;

import java.util.List;

public class AudioRepository {

    private final AudioDataDao dao;

    public AudioRepository(Context context) {
        AppDatabase appDatabase = AppDatabase.getInstance(context);
        dao = appDatabase.audioDataDao();
    }

    public void insertAll(List<AudioData> audioDataList) {
        new Thread(() -> dao.insertAll(audioDataList)).start();
    }

    public void update(AudioData audioData) {
        new Thread(() -> dao.update(audioData)).start();
    }

    public LiveData<List<AudioData>> getFirstCategory() {
        return dao.getFirstCategory();
    }

    public LiveData<List<AudioData>> getCategory(String name) {
        return dao.getCategory(name);
    }

    public LiveData<List<AudioData>> getFavorite() {
        return dao.getFavorite();
    }

}
