2855 Cancel UI media info update when fragment is destroyed

This commit is contained in:
Martin Fietz 2018-10-13 12:08:23 +02:00
parent 2d4739bd84
commit 2a067df6d1
2 changed files with 13 additions and 11 deletions

View File

@ -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"

View File

@ -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();
@ -142,6 +143,9 @@ public class ExternalPlayerFragment extends Fragment {
if (controller != null) {
controller.release();
}
if (subscription != null) {
subscription.unsubscribe();
}
}
@Override
@ -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));
@ -210,11 +217,6 @@ public class ExternalPlayerFragment extends Fragment {
}
}
private String getPositionString(int position, int duration) {
return Converter.getDurationStringLong(position) + " / "
+ Converter.getDurationStringLong(duration);
}
public PlaybackController getPlaybackControllerTestingOnly() {
return controller;
}