Stop playback of deleted podcast even if it is just streaming

This commit is contained in:
ByteHamster 2021-03-07 10:48:54 +01:00
parent f6e3843813
commit db70129537
2 changed files with 13 additions and 4 deletions

View File

@ -196,10 +196,17 @@ public class DBWriter {
if (queue.remove(item)) {
removedFromQueue.add(item);
}
if (item.getMedia() != null && item.getMedia().isDownloaded()) {
deleteFeedMediaSynchronous(context, item.getMedia());
} else if (item.getMedia() != null && requester.isDownloadingFile(item.getMedia())) {
requester.cancelDownload(context, item.getMedia());
if (item.getMedia() != null) {
if (item.getMedia().getId() == PlaybackPreferences.getCurrentlyPlayingFeedMediaId()) {
// Applies to both downloaded and streamed media
PlaybackPreferences.writeNoMediaPlaying();
IntentUtils.sendLocalBroadcast(context, PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE);
}
if (item.getMedia().isDownloaded()) {
deleteFeedMediaSynchronous(context, item.getMedia());
} else if (requester.isDownloadingFile(item.getMedia())) {
requester.cancelDownload(context, item.getMedia());
}
}
}

View File

@ -11,6 +11,7 @@ import androidx.documentfile.provider.AssetsDocumentFile;
import androidx.documentfile.provider.DocumentFile;
import androidx.test.platform.app.InstrumentationRegistry;
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@ -67,6 +68,7 @@ public class LocalFeedUpdaterTest {
// Initialize environment
context = InstrumentationRegistry.getInstrumentation().getContext();
UserPreferences.init(context);
PlaybackPreferences.init(context);
Application app = (Application) context;
ClientConfig.applicationCallbacks = mock(ApplicationCallbacks.class);