summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Fietz <martin.fietz@gmail.com>2018-10-13 12:08:23 +0200
committerMartin Fietz <martin.fietz@gmail.com>2018-10-13 12:09:06 +0200
commit2a067df6d197d1a525e65d3ce9f87a75a32fd1d0 (patch)
treedf5414a4bfee7e1dc622153f3f78536a07df2f9d
parent2d4739bd843bf522b06b128308c3284029b4a46c (diff)
downloadAntennaPod-2a067df6d197d1a525e65d3ce9f87a75a32fd1d0.zip
2855 Cancel UI media info update when fragment is destroyed
-rw-r--r--app/build.gradle2
-rw-r--r--app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java22
2 files changed, 13 insertions, 11 deletions
diff --git a/app/build.gradle b/app/build.gradle
index 281313628..a5cdf8a38 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -150,7 +150,7 @@ dependencies {
implementation "com.android.support:gridlayout-v7:$supportVersion"
implementation "com.android.support:percent:$supportVersion"
implementation "com.android.support:recyclerview-v7:$supportVersion"
- provided 'com.google.android.wearable:wearable:2.2.0'
+ compileOnly 'com.google.android.wearable:wearable:2.2.0'
implementation "org.apache.commons:commons-lang3:$commonslangVersion"
implementation("org.shredzone.flattr4j:flattr4j-core:$flattr4jVersion") {
exclude group: "org.json", module: "json"
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java
index dc0ea07ff..9e8c9731e 100644
--- a/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java
@@ -20,10 +20,10 @@ import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.feed.MediaType;
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.playback.Playable;
import de.danoeh.antennapod.core.util.playback.PlaybackController;
import rx.Single;
+import rx.Subscription;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
@@ -41,6 +41,7 @@ public class ExternalPlayerFragment extends Fragment {
private TextView mFeedName;
private ProgressBar mProgressBar;
private PlaybackController controller;
+ private Subscription subscription;
public ExternalPlayerFragment() {
super();
@@ -81,7 +82,7 @@ public class ExternalPlayerFragment extends Fragment {
super.onActivityCreated(savedInstanceState);
controller = setupPlaybackController();
butPlay.setOnClickListener(v -> {
- if(controller != null) {
+ if (controller != null) {
controller.playPause();
}
});
@@ -142,6 +143,9 @@ public class ExternalPlayerFragment extends Fragment {
if (controller != null) {
controller.release();
}
+ if (subscription != null) {
+ subscription.unsubscribe();
+ }
}
@Override
@@ -162,7 +166,7 @@ public class ExternalPlayerFragment extends Fragment {
controller = setupPlaybackController();
if (butPlay != null) {
butPlay.setOnClickListener(v -> {
- if(controller != null) {
+ if (controller != null) {
controller.playPause();
}
});
@@ -177,7 +181,10 @@ public class ExternalPlayerFragment extends Fragment {
return false;
}
- Single.create(subscriber -> subscriber.onSuccess(controller.getMedia()))
+ if (subscription != null) {
+ subscription.unsubscribe();
+ }
+ subscription = Single.create(subscriber -> subscriber.onSuccess(controller.getMedia()))
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(media -> updateUi((Playable) media));
@@ -206,15 +213,10 @@ public class ExternalPlayerFragment extends Fragment {
butPlay.setVisibility(View.VISIBLE);
}
} else {
- Log.w(TAG, "loadMediaInfo was called while the media object of playbackService was null!");
+ Log.w(TAG, "loadMediaInfo was called while the media object of playbackService was null!");
}
}
- private String getPositionString(int position, int duration) {
- return Converter.getDurationStringLong(position) + " / "
- + Converter.getDurationStringLong(duration);
- }
-
public PlaybackController getPlaybackControllerTestingOnly() {
return controller;
}