mirror of
https://github.com/NiciDieNase/chaosflix
synced 2024-11-12 23:57:11 +00:00
Leanback: reenable inProgress list
This commit is contained in:
parent
ccd7dfb2cf
commit
30928f862d
3 changed files with 17 additions and 8 deletions
|
@ -9,10 +9,11 @@ import androidx.room.Query
|
|||
@Dao
|
||||
interface PlaybackProgressDao {
|
||||
|
||||
@Query("""SELECT event.*, progress.progress, progress.watch_date, conference.acronym as conference
|
||||
FROM playback_progress as progress
|
||||
@Query("""SELECT event.*, p.progress, p.watch_date, conference.acronym as conference
|
||||
FROM playback_progress as p
|
||||
JOIN event ON event_guid = event.guid
|
||||
JOIN conference ON event.conferenceId = conference.id""")
|
||||
JOIN conference ON event.conferenceId = conference.id
|
||||
ORDER BY p.watch_date DESC""")
|
||||
fun getInProgessEvents(): LiveData<List<ProgressEventView>>
|
||||
|
||||
@Query("SELECT * from playback_progress")
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package de.nicidienase.chaosflix.common.viewmodel
|
||||
|
||||
import android.util.Log
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.Transformations
|
||||
|
@ -75,7 +76,8 @@ class BrowseViewModel(
|
|||
return itemDao.getWatchlistEvents()
|
||||
}
|
||||
|
||||
fun getInProgressEvents(): LiveData<List<Event>> {
|
||||
@JvmOverloads
|
||||
fun getInProgressEvents(filterFinished: Boolean = false): LiveData<List<Event>> {
|
||||
val dao = database.playbackProgressDao()
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
dao.getAllSync().forEach {
|
||||
|
@ -84,7 +86,13 @@ class BrowseViewModel(
|
|||
}
|
||||
return Transformations.map(dao.getInProgessEvents()) { list ->
|
||||
list.forEach { it.event.progress = it.progress }
|
||||
list.map { it.event }
|
||||
if(filterFinished){
|
||||
val result = list.partition { it.progress / 1000 > (it.event.length - 10) }
|
||||
Log.d(TAG, "Filtered ${result.first.size} finished items: ${result.first.map { "${it.progress / 1000}-${it.event.length}|"}}")
|
||||
result.second.map { it.event }
|
||||
} else {
|
||||
list.map { it.event }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -144,7 +144,7 @@ class ConferencesBrowseFragment : BrowseSupportFragment() {
|
|||
}
|
||||
}
|
||||
})
|
||||
viewModel.getInProgressEvents().observe(viewLifecycleOwner, Observer { inProgress ->
|
||||
viewModel.getInProgressEvents(filterFinished = true).observe(viewLifecycleOwner, Observer { inProgress ->
|
||||
if (inProgress != null) {
|
||||
inProgressAdapter.setItems(inProgress, DiffCallbacks.eventDiffCallback)
|
||||
inProgressAdapter.notifyItemRangeChanged(0, inProgress.size)
|
||||
|
@ -182,8 +182,8 @@ class ConferencesBrowseFragment : BrowseSupportFragment() {
|
|||
Section.Recommendations,
|
||||
{ listOf(
|
||||
promotedRow,
|
||||
watchlistRow // ,
|
||||
// inProgressRow
|
||||
watchlistRow,
|
||||
inProgressRow
|
||||
).filter { it.adapter.size() > 0 } },
|
||||
recomendationsDivider)
|
||||
|
||||
|
|
Loading…
Reference in a new issue