Check if we are deleting an episode that is currently playing or paused
This commit is contained in:
parent
61e3d3b2a6
commit
d9726d2543
|
@ -43,15 +43,13 @@ import de.danoeh.antennapod.core.event.ProgressEvent;
|
||||||
import de.danoeh.antennapod.core.event.QueueEvent;
|
import de.danoeh.antennapod.core.event.QueueEvent;
|
||||||
import de.danoeh.antennapod.core.feed.EventDistributor;
|
import de.danoeh.antennapod.core.feed.EventDistributor;
|
||||||
import de.danoeh.antennapod.core.feed.Feed;
|
import de.danoeh.antennapod.core.feed.Feed;
|
||||||
import de.danoeh.antennapod.core.feed.FeedMedia;
|
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
|
||||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||||
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||||
import de.danoeh.antennapod.core.service.playback.PlayerStatus;
|
|
||||||
import de.danoeh.antennapod.core.storage.DBReader;
|
import de.danoeh.antennapod.core.storage.DBReader;
|
||||||
import de.danoeh.antennapod.core.storage.DBWriter;
|
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||||
|
import de.danoeh.antennapod.core.util.FeedItemUtil;
|
||||||
import de.danoeh.antennapod.core.util.StorageUtils;
|
import de.danoeh.antennapod.core.util.StorageUtils;
|
||||||
import de.danoeh.antennapod.core.util.playback.Playable;
|
|
||||||
import de.danoeh.antennapod.core.util.playback.PlaybackController;
|
|
||||||
import de.danoeh.antennapod.dialog.RatingDialog;
|
import de.danoeh.antennapod.dialog.RatingDialog;
|
||||||
import de.danoeh.antennapod.fragment.AddFeedFragment;
|
import de.danoeh.antennapod.fragment.AddFeedFragment;
|
||||||
import de.danoeh.antennapod.fragment.DownloadsFragment;
|
import de.danoeh.antennapod.fragment.DownloadsFragment;
|
||||||
|
@ -567,23 +565,17 @@ public class MainActivity extends AppCompatActivity implements NavDrawerActivity
|
||||||
public void onConfirmButtonPressed(
|
public void onConfirmButtonPressed(
|
||||||
DialogInterface dialog) {
|
DialogInterface dialog) {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
if (externalPlayerFragment != null) {
|
long mediaId = PlaybackPreferences.getCurrentlyPlayingFeedMediaId();
|
||||||
PlaybackController controller = externalPlayerFragment.getPlaybackControllerTestingOnly();
|
if (mediaId > 0 &&
|
||||||
if (controller != null) {
|
FeedItemUtil.indexOfItemWithMediaId(feed.getItems(), mediaId) >= 0) {
|
||||||
Playable playable = controller.getMedia();
|
|
||||||
if (playable != null && playable instanceof FeedMedia) {
|
|
||||||
FeedMedia media = (FeedMedia) playable;
|
|
||||||
if (media.getItem().getFeed().getId() == feed.getId()) {
|
|
||||||
Log.d(TAG, "Currently playing episode is about to be deleted, skipping");
|
Log.d(TAG, "Currently playing episode is about to be deleted, skipping");
|
||||||
remover.skipOnCompletion = true;
|
remover.skipOnCompletion = true;
|
||||||
if(controller.getStatus() == PlayerStatus.PLAYING) {
|
int playerStatus = PlaybackPreferences.getCurrentPlayerStatus();
|
||||||
|
if(playerStatus == PlaybackPreferences.PLAYER_STATUS_PLAYING) {
|
||||||
sendBroadcast(new Intent(
|
sendBroadcast(new Intent(
|
||||||
PlaybackService.ACTION_PAUSE_PLAY_CURRENT_EPISODE));
|
PlaybackService.ACTION_PAUSE_PLAY_CURRENT_EPISODE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
remover.executeAsync();
|
remover.executeAsync();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue