feat: add functionality to delete podcast episodes and channels via bottom sheet

This commit is contained in:
antonio 2023-06-04 19:38:24 +02:00
parent 675ad1e9a6
commit 0248187f41
13 changed files with 336 additions and 82 deletions

View file

@ -1,29 +0,0 @@
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.subsonic.models.PodcastEpisode;
public class PodcastBottomSheetViewModel extends AndroidViewModel {
private final PodcastRepository podcastRepository;
private PodcastEpisode podcast;
public PodcastBottomSheetViewModel(@NonNull Application application) {
super(application);
podcastRepository = new PodcastRepository();
}
public PodcastEpisode getPodcast() {
return podcast;
}
public void setPodcast(PodcastEpisode podcast) {
this.podcast = podcast;
}
}

View file

@ -0,0 +1,34 @@
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.subsonic.models.PodcastChannel;
import com.cappielloantonio.play.subsonic.models.PodcastEpisode;
public class PodcastChannelBottomSheetViewModel extends AndroidViewModel {
private final PodcastRepository podcastRepository;
private PodcastChannel podcastChannel;
public PodcastChannelBottomSheetViewModel(@NonNull Application application) {
super(application);
podcastRepository = new PodcastRepository();
}
public PodcastChannel getPodcastChannel() {
return podcastChannel;
}
public void setPodcastChannel(PodcastChannel podcastChannel) {
this.podcastChannel = podcastChannel;
}
public void deletePodcastChannel() {
if (podcastChannel != null) podcastRepository.deletePodcastChannel(podcastChannel.getId());
}
}

View file

@ -0,0 +1,33 @@
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.subsonic.models.PodcastEpisode;
public class PodcastEpisodeBottomSheetViewModel extends AndroidViewModel {
private final PodcastRepository podcastRepository;
private PodcastEpisode podcastEpisode;
public PodcastEpisodeBottomSheetViewModel(@NonNull Application application) {
super(application);
podcastRepository = new PodcastRepository();
}
public PodcastEpisode getPodcastEpisode() {
return podcastEpisode;
}
public void setPodcastEpisode(PodcastEpisode podcast) {
this.podcastEpisode = podcast;
}
public void deletePodcastEpisode() {
if (podcastEpisode != null) podcastRepository.deletePodcastEpisode(podcastEpisode.getId());
}
}