add watched callback for next episode
This commit is contained in:
parent
0f0573e5bd
commit
3880b3ab75
|
@ -26,6 +26,7 @@ import kotlinx.android.synthetic.main.player_controls.*
|
|||
import kotlinx.coroutines.*
|
||||
import org.mosad.teapod.parser.AoDParser
|
||||
import org.mosad.teapod.preferences.Preferences
|
||||
import org.mosad.teapod.ui.fragments.MediaFragment
|
||||
import org.mosad.teapod.util.DataTypes.MediaType
|
||||
import org.mosad.teapod.util.Episode
|
||||
import org.mosad.teapod.util.Media
|
||||
|
@ -266,8 +267,7 @@ class PlayerActivity : AppCompatActivity() {
|
|||
|
||||
private fun playNextEpisode() {
|
||||
nextEpisode?.let { nextEp ->
|
||||
currentEpisode = nextEp // set current ep to next ep
|
||||
episodeId = nextEp.id
|
||||
|
||||
|
||||
// update the gui
|
||||
exo_text_title.text = nextEp.title
|
||||
|
@ -279,6 +279,11 @@ class PlayerActivity : AppCompatActivity() {
|
|||
player.setMediaSource(mediaSource)
|
||||
player.prepare()
|
||||
|
||||
// watchedCallback for next ep
|
||||
currentEpisode = nextEp // set current ep to next ep
|
||||
episodeId = nextEp.id
|
||||
MediaFragment.instance.updateWatchedState(nextEp) // TODO i don't like this
|
||||
|
||||
nextEpisode = selectNextEpisode()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,14 @@ class MediaFragment(private val media: Media, private val tmdb: TMDBResponse) :
|
|||
private lateinit var viewManager: RecyclerView.LayoutManager
|
||||
private lateinit var nextEpisode: Episode
|
||||
|
||||
companion object {
|
||||
lateinit var instance: MediaFragment
|
||||
}
|
||||
|
||||
init {
|
||||
instance = this
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.fragment_media, container, false)
|
||||
}
|
||||
|
@ -134,9 +142,10 @@ class MediaFragment(private val media: Media, private val tmdb: TMDBResponse) :
|
|||
playStream(ep)
|
||||
|
||||
// update watched state
|
||||
AoDParser.sendCallback(ep.watchedCallback)
|
||||
adapterRecEpisodes.updateWatchedState(true, media.episodes.indexOf(ep))
|
||||
adapterRecEpisodes.notifyDataSetChanged()
|
||||
updateWatchedState(ep)
|
||||
//AoDParser.sendCallback(ep.watchedCallback)
|
||||
//adapterRecEpisodes.updateWatchedState(true, media.episodes.indexOf(ep))
|
||||
//adapterRecEpisodes.notifyDataSetChanged()
|
||||
|
||||
// update nextEpisode
|
||||
nextEpisode = if (media.episodes.firstOrNull{ !it.watched } != null) {
|
||||
|
@ -152,4 +161,11 @@ class MediaFragment(private val media: Media, private val tmdb: TMDBResponse) :
|
|||
(activity as MainActivity).startPlayer(media.id, ep.id)
|
||||
}
|
||||
|
||||
fun updateWatchedState(ep: Episode) {
|
||||
AoDParser.sendCallback(ep.watchedCallback)
|
||||
adapterRecEpisodes.updateWatchedState(true, media.episodes.indexOf(ep))
|
||||
adapterRecEpisodes.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue