package com.wallpaper.wallpaperbox.ui.viewmodel;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;

import com.wallpaper.wallpaperbox.data.dao.WallpaperEntityDao;
import com.wallpaper.wallpaperbox.data.database.AppDatabase;
import com.wallpaper.wallpaperbox.data.entity.WallpaperEntity;
import com.wallpaper.wallpaperbox.data.repository.WallpaperRepository;

import java.util.List;

public class WallpaperViewModel extends AndroidViewModel {
    private final WallpaperRepository wallpaperRepository;

    public WallpaperViewModel(@NonNull Application application) {
        super(application);
        WallpaperEntityDao wallpaperInfoDao = AppDatabase.getInstance(application).wallpaperEntityDao();
        wallpaperRepository = new WallpaperRepository(wallpaperInfoDao);
    }

    public void update(WallpaperEntity wallpaperEntity) {
        wallpaperRepository.update(wallpaperEntity);
    }

    public LiveData<List<WallpaperEntity>> getFirstWallpaper() {
        return wallpaperRepository.getFirstWallpaper();
    }

    public LiveData<List<WallpaperEntity>> getLike() {
        return wallpaperRepository.getLike();
    }

    public LiveData<List<WallpaperEntity>> getCategoryByName(String name) {
        return wallpaperRepository.getCategoryByName(name);
    }

    public LiveData<Boolean> getWallpaperLike(String source, String name) {
        return wallpaperRepository.getWallpaperLike(source, name);
    }
}
