mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-01-27 09:01:22 +01:00
Merge pull request #2760 from ByteHamster/delete-item
Improve item deletion
This commit is contained in:
commit
fc2bd0e19b
@ -16,6 +16,7 @@ import com.bumptech.glide.Glide;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||
import de.danoeh.antennapod.core.glide.ApGlideSettings;
|
||||
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||
import de.danoeh.antennapod.core.util.Converter;
|
||||
import de.danoeh.antennapod.core.util.DateUtils;
|
||||
|
||||
@ -98,7 +99,7 @@ public class DownloadedEpisodesListAdapter extends BaseAdapter {
|
||||
holder.pubDate.setText(pubDateStr);
|
||||
|
||||
FeedItem.State state = item.getState();
|
||||
if (state == FeedItem.State.PLAYING) {
|
||||
if (state == FeedItem.State.PLAYING && PlaybackService.isRunning) {
|
||||
holder.butSecondary.setEnabled(false);
|
||||
holder.butSecondary.setAlpha(0.5f);
|
||||
} else {
|
||||
|
@ -436,7 +436,7 @@ public class ItemFragment extends Fragment implements OnSwipeGesture {
|
||||
}
|
||||
|
||||
FeedItem.State state = item.getState();
|
||||
if (butAction2Text == R.string.delete_label && state == FeedItem.State.PLAYING) {
|
||||
if (butAction2Text == R.string.delete_label && state == FeedItem.State.PLAYING && PlaybackService.isRunning) {
|
||||
butAction2.setEnabled(false);
|
||||
butAction2.setAlpha(0.5f);
|
||||
} else {
|
||||
|
@ -341,6 +341,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
Log.d(TAG, "Service is about to be destroyed");
|
||||
stopForeground(true);
|
||||
isRunning = false;
|
||||
started = false;
|
||||
currentMediaType = MediaType.UNKNOWN;
|
||||
@ -363,6 +364,11 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||
mediaPlayer.shutdown();
|
||||
taskManager.shutdown();
|
||||
}
|
||||
|
||||
private void stopService() {
|
||||
stopForeground(true);
|
||||
stopSelf();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BrowserRoot onGetRoot(@NonNull String clientPackageName, int clientUid, Bundle rootHints) {
|
||||
@ -458,7 +464,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||
Playable playable = intent.getParcelableExtra(EXTRA_PLAYABLE);
|
||||
if (keycode == -1 && playable == null && !castDisconnect) {
|
||||
Log.e(TAG, "PlaybackService was started with no arguments");
|
||||
stopSelf();
|
||||
stopService();
|
||||
return Service.START_NOT_STICKY;
|
||||
}
|
||||
|
||||
@ -470,7 +476,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||
Log.d(TAG, "Received media button event");
|
||||
boolean handled = handleKeycode(keycode, true);
|
||||
if (!handled) {
|
||||
stopSelf();
|
||||
stopService();
|
||||
return Service.START_NOT_STICKY;
|
||||
}
|
||||
} else if (!flavorHelper.castDisconnect(castDisconnect) && playable != null) {
|
||||
@ -680,7 +686,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||
|
||||
case STOPPED:
|
||||
//writePlaybackPreferencesNoMediaPlaying();
|
||||
//stopSelf();
|
||||
//stopService();
|
||||
break;
|
||||
|
||||
case PLAYING:
|
||||
@ -697,7 +703,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||
|
||||
case ERROR:
|
||||
writePlaybackPreferencesNoMediaPlaying();
|
||||
stopSelf();
|
||||
stopService();
|
||||
break;
|
||||
|
||||
}
|
||||
@ -710,7 +716,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||
|
||||
@Override
|
||||
public void shouldStop() {
|
||||
stopSelf();
|
||||
stopService();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -759,7 +765,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||
}
|
||||
sendNotificationBroadcast(NOTIFICATION_TYPE_ERROR, what);
|
||||
writePlaybackPreferencesNoMediaPlaying();
|
||||
stopSelf();
|
||||
stopService();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1213,7 +1219,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||
if (playable == null) {
|
||||
Log.d(TAG, "setupNotification: playable is null");
|
||||
if (!started) {
|
||||
stopSelf();
|
||||
stopService();
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -1227,7 +1233,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||
if (mediaPlayer == null) {
|
||||
Log.d(TAG, "notificationSetupTask: mediaPlayer is null");
|
||||
if (!started) {
|
||||
stopSelf();
|
||||
stopService();
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -1548,7 +1554,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (TextUtils.equals(intent.getAction(), ACTION_SHUTDOWN_PLAYBACK_SERVICE)) {
|
||||
stopSelf();
|
||||
stopService();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user