Skip to content

Commit

Permalink
Fix periodic spinner showing during playback
Browse files Browse the repository at this point in the history
  • Loading branch information
kingargyle committed Oct 31, 2018
1 parent 6a4ceb3 commit 8824a82
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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:
* <p>
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
* <p>
* 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
Expand Down
Original file line number Diff line number Diff line change
@@ -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:
* <p>
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
* <p>
* 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ interface ExoplayerContract {
fun hideLoadingProgress()

fun showLoadingProgress()

fun playbackEnded()
}

interface ExoplayerPresenter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ class ExoplayerPresenter : MvpPresenter<ExoplayerContract.ExoplayerView>(), 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 {
Expand All @@ -108,11 +114,6 @@ class ExoplayerPresenter : MvpPresenter<ExoplayerContract.ExoplayerView>(), Exop
}

override fun onLoadingChanged(isLoading: Boolean) {
if (isLoading) {
viewState.showLoadingProgress()
} else {
viewState.hideLoadingProgress()
}
}

override fun onRepeatModeChanged(repeatMode: Int) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 8824a82

Please sign in to comment.