diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2012-09-25 13:37:47 +0200 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2012-09-25 13:37:47 +0200 |
commit | 88b3a015cd9cd4f793f0aaa984b878bb94303ae4 (patch) | |
tree | 4f2360e057c5c7442b9f84b2844b2e6b08f4313d /src/de/danoeh/antennapod/util/PlaybackController.java | |
parent | d39bd6831bea56b2e93f98107d630aa6d9056fdf (diff) | |
download | AntennaPod-88b3a015cd9cd4f793f0aaa984b878bb94303ae4.zip |
Feeds weren't always deleted properly
Diffstat (limited to 'src/de/danoeh/antennapod/util/PlaybackController.java')
-rw-r--r-- | src/de/danoeh/antennapod/util/PlaybackController.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/de/danoeh/antennapod/util/PlaybackController.java b/src/de/danoeh/antennapod/util/PlaybackController.java index 6ac7de0ca..cb7b0c1bd 100644 --- a/src/de/danoeh/antennapod/util/PlaybackController.java +++ b/src/de/danoeh/antennapod/util/PlaybackController.java @@ -116,7 +116,16 @@ public abstract class PlaybackController { } catch (IllegalArgumentException e) { // ignore } + + try { + activity.unregisterReceiver(shutdownReceiver); + } catch (IllegalArgumentException e) { + // ignore + } cancelPositionObserver(); + schedExecutor.shutdownNow(); + media = null; + } /** Should be called in the activity's onPause() method. */ @@ -226,6 +235,9 @@ public abstract class PlaybackController { activity.registerReceiver(notificationReceiver, new IntentFilter( PlaybackService.ACTION_PLAYER_NOTIFICATION)); + activity.registerReceiver(shutdownReceiver, new IntentFilter( + PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE)); + queryService(); if (AppConfig.DEBUG) Log.d(TAG, "Connection to Service established"); @@ -300,6 +312,20 @@ public abstract class PlaybackController { }; + private BroadcastReceiver shutdownReceiver = new BroadcastReceiver() { + + @Override + public void onReceive(Context context, Intent intent) { + if (intent.getAction().equals( + PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE)) { + release(); + onShutdownNotification(); + } + } + }; + + public abstract void onShutdownNotification(); + /** Called when the currently displayed information should be refreshed. */ public abstract void onReloadNotification(int code); |