2023-06-17 15:30:23 +02:00
|
|
|
package com.cappielloantonio.tempo.viewmodel;
|
2021-09-13 11:28:48 +02:00
|
|
|
|
|
|
|
|
import android.app.Application;
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
import androidx.lifecycle.AndroidViewModel;
|
|
|
|
|
import androidx.lifecycle.LifecycleOwner;
|
|
|
|
|
import androidx.lifecycle.LiveData;
|
|
|
|
|
import androidx.lifecycle.MutableLiveData;
|
|
|
|
|
|
2023-06-17 15:30:23 +02:00
|
|
|
import com.cappielloantonio.tempo.repository.SongRepository;
|
|
|
|
|
import com.cappielloantonio.tempo.subsonic.models.Child;
|
2021-09-13 11:28:48 +02:00
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
public class StarredSyncViewModel extends AndroidViewModel {
|
|
|
|
|
private final SongRepository songRepository;
|
|
|
|
|
|
2023-03-06 21:59:10 +01:00
|
|
|
private final MutableLiveData<List<Child>> starredTracks = new MutableLiveData<>(null);
|
2021-09-13 11:28:48 +02:00
|
|
|
|
|
|
|
|
public StarredSyncViewModel(@NonNull Application application) {
|
|
|
|
|
super(application);
|
|
|
|
|
|
2023-03-10 15:21:02 +01:00
|
|
|
songRepository = new SongRepository();
|
2021-09-13 11:28:48 +02:00
|
|
|
}
|
|
|
|
|
|
2023-03-06 21:59:10 +01:00
|
|
|
public LiveData<List<Child>> getStarredTracks(LifecycleOwner owner) {
|
2021-09-13 11:28:48 +02:00
|
|
|
songRepository.getStarredSongs(false, -1).observe(owner, starredTracks::postValue);
|
|
|
|
|
return starredTracks;
|
|
|
|
|
}
|
|
|
|
|
}
|