feat: add ability to add podcast channels

This commit is contained in:
antonio 2023-06-04 20:43:08 +02:00
parent 0248187f41
commit 7f4be7ad3e
10 changed files with 204 additions and 2 deletions

View file

@ -0,0 +1,28 @@
package com.cappielloantonio.play.viewmodel;
import android.app.Application;
import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import com.cappielloantonio.play.repository.PodcastRepository;
import com.cappielloantonio.play.repository.RadioRepository;
import com.cappielloantonio.play.subsonic.models.InternetRadioStation;
public class PodcastChannelEditorViewModel extends AndroidViewModel {
private static final String TAG = "RadioEditorViewModel";
private final PodcastRepository podcastRepository;
private InternetRadioStation toEdit;
public PodcastChannelEditorViewModel(@NonNull Application application) {
super(application);
podcastRepository = new PodcastRepository();
}
public void createChannel(String url) {
podcastRepository.createPodcastChannel(url);
}
}

View file

@ -41,4 +41,12 @@ public class PodcastViewModel extends AndroidViewModel {
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);
}
}