summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaniel oeh <daniel.oeh@gmail.com>2012-09-26 12:51:59 +0200
committerdaniel oeh <daniel.oeh@gmail.com>2012-09-26 12:51:59 +0200
commit14d05bde1c21e0720d48dfba8b0095b6c50323d0 (patch)
tree8f74ec237bba05ac30e59c06dd7deeeaabef5ad8 /src
parentff364f13f99c021657cdaceaf25728d8a33afa2d (diff)
downloadAntennaPod-14d05bde1c21e0720d48dfba8b0095b6c50323d0.zip
Release PlaybackController in onDestroy() method in MediaplayerActivity
Diffstat (limited to 'src')
-rw-r--r--src/de/danoeh/antennapod/activity/MediaplayerActivity.java11
-rw-r--r--src/de/danoeh/antennapod/util/PlaybackController.java12
2 files changed, 19 insertions, 4 deletions
diff --git a/src/de/danoeh/antennapod/activity/MediaplayerActivity.java b/src/de/danoeh/antennapod/activity/MediaplayerActivity.java
index 91f2f99a2..45c5f55a5 100644
--- a/src/de/danoeh/antennapod/activity/MediaplayerActivity.java
+++ b/src/de/danoeh/antennapod/activity/MediaplayerActivity.java
@@ -186,7 +186,16 @@ public abstract class MediaplayerActivity extends SherlockFragmentActivity
super.onStop();
if (AppConfig.DEBUG)
Log.d(TAG, "Activity stopped");
- controller.release();
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ if (AppConfig.DEBUG)
+ Log.d(TAG, "Activity destroyed");
+ if (controller != null) {
+ controller.release();
+ }
}
@Override
diff --git a/src/de/danoeh/antennapod/util/PlaybackController.java b/src/de/danoeh/antennapod/util/PlaybackController.java
index bb9c5dd5a..f29f42707 100644
--- a/src/de/danoeh/antennapod/util/PlaybackController.java
+++ b/src/de/danoeh/antennapod/util/PlaybackController.java
@@ -55,6 +55,7 @@ public abstract class PlaybackController {
protected ScheduledFuture positionObserverFuture;
private boolean mediaInfoLoaded = false;
+ private boolean released = false;
public PlaybackController(Activity activity) {
this.activity = activity;
@@ -83,7 +84,12 @@ public abstract class PlaybackController {
* activity's onResume() method.
*/
public void init() {
- bindToService();
+ if (!released) {
+ bindToService();
+ } else {
+ throw new IllegalStateException(
+ "Can't call init() after release() has been called");
+ }
}
/**
@@ -111,7 +117,7 @@ public abstract class PlaybackController {
} catch (IllegalArgumentException e) {
// ignore
}
-
+
try {
activity.unregisterReceiver(shutdownReceiver);
} catch (IllegalArgumentException e) {
@@ -120,6 +126,7 @@ public abstract class PlaybackController {
cancelPositionObserver();
schedExecutor.shutdownNow();
media = null;
+ released = true;
}
@@ -534,7 +541,6 @@ public abstract class PlaybackController {
}
}
-
public int getDuration() {
if (playbackService != null) {
return playbackService.getDurationSafe();