diff options
author | Martin Fietz <martin.fietz@gmail.com> | 2018-10-13 12:08:23 +0200 |
---|---|---|
committer | Martin Fietz <martin.fietz@gmail.com> | 2018-10-13 12:09:06 +0200 |
commit | 2a067df6d197d1a525e65d3ce9f87a75a32fd1d0 (patch) | |
tree | df5414a4bfee7e1dc622153f3f78536a07df2f9d /app/src/main | |
parent | 2d4739bd843bf522b06b128308c3284029b4a46c (diff) | |
download | AntennaPod-2a067df6d197d1a525e65d3ce9f87a75a32fd1d0.zip |
2855 Cancel UI media info update when fragment is destroyed
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java | 22 |
1 files changed, 12 insertions, 10 deletions
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; } |