mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2024-12-25 00:14:00 +01:00
Merge pull request #2856 from AntennaPod/bugfix/2855-ias-external-player
2855 Cancel UI media info update when fragment is destroyed
This commit is contained in:
commit
a637725093
@ -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"
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user