From 8824a82600eacac5ba547c05219f0377191486db Mon Sep 17 00:00:00 2001 From: David Carver Date: Tue, 30 Oct 2018 23:26:08 -0400 Subject: [PATCH] Fix periodic spinner showing during playback --- .../FocusableLinearLayoutManager.kt | 23 +++++++++++++++++++ .../FocusableLinearSmoothScroller.kt | 22 ++++++++++++++++++ .../ui/video/player/ExoplayerContract.kt | 2 ++ .../ui/video/player/ExoplayerPresenter.kt | 11 +++++---- .../ui/video/player/ExoplayerVideoActivity.kt | 4 ++++ 5 files changed, 57 insertions(+), 5 deletions(-) diff --git a/serenity-app/src/main/kotlin/us/nineworlds/serenity/ui/recyclerview/FocusableLinearLayoutManager.kt b/serenity-app/src/main/kotlin/us/nineworlds/serenity/ui/recyclerview/FocusableLinearLayoutManager.kt index bb29c9fe5..cff06545d 100644 --- a/serenity-app/src/main/kotlin/us/nineworlds/serenity/ui/recyclerview/FocusableLinearLayoutManager.kt +++ b/serenity-app/src/main/kotlin/us/nineworlds/serenity/ui/recyclerview/FocusableLinearLayoutManager.kt @@ -1,5 +1,28 @@ package us.nineworlds.serenity.ui.recyclerview +/** + * The MIT License (MIT) + * Copyright (c) 2018 David Carver + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + *

+ * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + *

+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS + * OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + import android.content.Context import android.support.v7.widget.LinearLayoutManager import android.support.v7.widget.RecyclerView diff --git a/serenity-app/src/main/kotlin/us/nineworlds/serenity/ui/recyclerview/FocusableLinearSmoothScroller.kt b/serenity-app/src/main/kotlin/us/nineworlds/serenity/ui/recyclerview/FocusableLinearSmoothScroller.kt index 19fab2a50..8f12fe9f3 100644 --- a/serenity-app/src/main/kotlin/us/nineworlds/serenity/ui/recyclerview/FocusableLinearSmoothScroller.kt +++ b/serenity-app/src/main/kotlin/us/nineworlds/serenity/ui/recyclerview/FocusableLinearSmoothScroller.kt @@ -1,4 +1,26 @@ package us.nineworlds.serenity.ui.recyclerview +/** + * The MIT License (MIT) + * Copyright (c) 2018 David Carver + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + *

+ * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + *

+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS + * OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF + * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ import android.content.Context import android.support.v7.widget.LinearSmoothScroller diff --git a/serenity-app/src/main/kotlin/us/nineworlds/serenity/ui/video/player/ExoplayerContract.kt b/serenity-app/src/main/kotlin/us/nineworlds/serenity/ui/video/player/ExoplayerContract.kt index 67b6a0c37..61684acb1 100644 --- a/serenity-app/src/main/kotlin/us/nineworlds/serenity/ui/video/player/ExoplayerContract.kt +++ b/serenity-app/src/main/kotlin/us/nineworlds/serenity/ui/video/player/ExoplayerContract.kt @@ -19,6 +19,8 @@ interface ExoplayerContract { fun hideLoadingProgress() fun showLoadingProgress() + + fun playbackEnded() } interface ExoplayerPresenter { diff --git a/serenity-app/src/main/kotlin/us/nineworlds/serenity/ui/video/player/ExoplayerPresenter.kt b/serenity-app/src/main/kotlin/us/nineworlds/serenity/ui/video/player/ExoplayerPresenter.kt index 29d06d80e..1e095fda7 100644 --- a/serenity-app/src/main/kotlin/us/nineworlds/serenity/ui/video/player/ExoplayerPresenter.kt +++ b/serenity-app/src/main/kotlin/us/nineworlds/serenity/ui/video/player/ExoplayerPresenter.kt @@ -94,6 +94,12 @@ class ExoplayerPresenter : MvpPresenter(), Exop } override fun onPlayerStateChanged(playWhenReady: Boolean, playbackState: Int) { + if (Player.STATE_ENDED == playbackState) { + stopPlaying() + viewState.playbackEnded() + return + } + if (Player.STATE_BUFFERING == playbackState) { viewState.showLoadingProgress() } else { @@ -108,11 +114,6 @@ class ExoplayerPresenter : MvpPresenter(), Exop } override fun onLoadingChanged(isLoading: Boolean) { - if (isLoading) { - viewState.showLoadingProgress() - } else { - viewState.hideLoadingProgress() - } } override fun onRepeatModeChanged(repeatMode: Int) { diff --git a/serenity-app/src/main/kotlin/us/nineworlds/serenity/ui/video/player/ExoplayerVideoActivity.kt b/serenity-app/src/main/kotlin/us/nineworlds/serenity/ui/video/player/ExoplayerVideoActivity.kt index e573eaa05..4abadca23 100644 --- a/serenity-app/src/main/kotlin/us/nineworlds/serenity/ui/video/player/ExoplayerVideoActivity.kt +++ b/serenity-app/src/main/kotlin/us/nineworlds/serenity/ui/video/player/ExoplayerVideoActivity.kt @@ -202,6 +202,10 @@ class ExoplayerVideoActivity : SerenityActivity(), ExoplayerContract.ExoplayerVi dataLoadingContainer.visibility = View.VISIBLE } + override fun playbackEnded() { + finish() + } + protected inner class ProgressRunnable : Runnable { override fun run() {