build: change of package name

This commit is contained in:
antonio 2023-06-17 15:30:23 +02:00
parent 49afdbe4eb
commit b76a38cb30
274 changed files with 1981 additions and 2161 deletions

View file

@ -0,0 +1,52 @@
package com.cappielloantonio.tempo.viewmodel;
import android.app.Application;
import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import com.cappielloantonio.tempo.repository.PodcastRepository;
import com.cappielloantonio.tempo.subsonic.models.PodcastChannel;
import com.cappielloantonio.tempo.subsonic.models.PodcastEpisode;
import java.util.List;
public class PodcastViewModel extends AndroidViewModel {
private final PodcastRepository podcastRepository;
private final MutableLiveData<List<PodcastEpisode>> newestPodcastEpisodes = new MutableLiveData<>(null);
private final MutableLiveData<List<PodcastChannel>> podcastChannels = new MutableLiveData<>(null);
public PodcastViewModel(@NonNull Application application) {
super(application);
podcastRepository = new PodcastRepository();
}
public LiveData<List<PodcastEpisode>> getNewestPodcastEpisodes(LifecycleOwner owner) {
if (newestPodcastEpisodes.getValue() == null) {
podcastRepository.getNewestPodcastEpisodes(20).observe(owner, newestPodcastEpisodes::postValue);
}
return newestPodcastEpisodes;
}
public LiveData<List<PodcastChannel>> getPodcastChannels(LifecycleOwner owner) {
if (podcastChannels.getValue() == null) {
podcastRepository.getPodcastChannels(false, null).observe(owner, podcastChannels::postValue);
}
return podcastChannels;
}
public void refreshNewestPodcastEpisodes(LifecycleOwner owner) {
podcastRepository.getNewestPodcastEpisodes(20).observe(owner, newestPodcastEpisodes::postValue);
}
public void refreshPodcastChannels(LifecycleOwner owner) {
podcastRepository.getPodcastChannels(false, null).observe(owner, podcastChannels::postValue);
}
}