diff options
author | H. Lehmann <ByteHamster@users.noreply.github.com> | 2019-04-11 20:50:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-11 20:50:56 +0200 |
commit | 97d08f3b00f864d421608ac52e42beafc37e323d (patch) | |
tree | a5f2061613f6a1f8fd73128f6d9f157d54abfe9b /app | |
parent | be6eb1c738beb7d5671647211d39d15c2edb235e (diff) | |
parent | 1d0e22135e57c7bcff8988c388d7f0f813ad7061 (diff) | |
download | AntennaPod-97d08f3b00f864d421608ac52e42beafc37e323d.zip |
Merge pull request #3097 from ByteHamster/exoplayer-main-thread
Executing all ExoPlayer methods on main thread
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java | 9 | ||||
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java | 38 |
2 files changed, 27 insertions, 20 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java index 9f4fbe271..3bbe206f8 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java @@ -776,15 +776,6 @@ public class MainActivity extends CastEnabledActivity implements NavDrawerActivi loadData(); } - public void onEventMainThread(ServiceEvent event) { - Log.d(TAG, "onEvent(" + event + ")"); - switch(event.action) { - case SERVICE_STARTED: - externalPlayerFragment.connectToPlaybackService(); - break; - } - } - public void onEventMainThread(ProgressEvent event) { Log.d(TAG, "onEvent(" + event + ")"); switch(event.action) { 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 de2f04590..2c35bdba4 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java @@ -18,11 +18,13 @@ import com.bumptech.glide.Glide; import com.bumptech.glide.request.RequestOptions; import de.danoeh.antennapod.R; +import de.danoeh.antennapod.core.event.ServiceEvent; 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.playback.Playable; import de.danoeh.antennapod.core.util.playback.PlaybackController; +import de.greenrobot.event.EventBus; import io.reactivex.Maybe; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; @@ -90,8 +92,11 @@ public class ExternalPlayerFragment extends Fragment { loadMediaInfo(); } - public void connectToPlaybackService() { - controller.init(); + public void onEventMainThread(ServiceEvent event) { + Log.d(TAG, "onEvent(" + event + ")"); + if (event.action == ServiceEvent.Action.SERVICE_STARTED) { + controller.init(); + } } private PlaybackController setupPlaybackController() { @@ -109,12 +114,12 @@ public class ExternalPlayerFragment extends Fragment { @Override public boolean loadMediaInfo() { - ExternalPlayerFragment fragment = ExternalPlayerFragment.this; - if (fragment != null) { - return fragment.loadMediaInfo(); - } else { - return false; - } + return ExternalPlayerFragment.this.loadMediaInfo(); + } + + @Override + public void setupGUI() { + ExternalPlayerFragment.this.loadMediaInfo(); } @Override @@ -133,17 +138,28 @@ public class ExternalPlayerFragment extends Fragment { public void onResume() { super.onResume(); onPositionObserverUpdate(); + } + @Override + public void onStart() { + super.onStart(); controller.init(); + EventBus.getDefault().register(this); } @Override - public void onDestroy() { - super.onDestroy(); - Log.d(TAG, "Fragment is about to be destroyed"); + public void onStop() { + super.onStop(); if (controller != null) { controller.release(); } + EventBus.getDefault().unregister(this); + } + + @Override + public void onDestroy() { + super.onDestroy(); + Log.d(TAG, "Fragment is about to be destroyed"); if (disposable != null) { disposable.dispose(); } |