mirror of
https://github.com/MatomoCamp/matomocamp-companion-android.git
synced 2024-09-19 16:13:46 +02:00
add all event view
This commit is contained in:
parent
da5e8645cf
commit
dd6bc628be
6 changed files with 30 additions and 3 deletions
|
@ -8,7 +8,7 @@ package org.matomocamp.companion.api
|
|||
object MatomoCampUrls {
|
||||
|
||||
val schedule
|
||||
get() = "https://fosdem.org/schedule/xml"
|
||||
get() = "https://schedule.matomocamp.org/matomocamp-2022/schedule/export/schedule.xml"
|
||||
val rooms
|
||||
get() = "https://api.fosdem.org/roomstatus/v1/listrooms"
|
||||
val localNavigation
|
||||
|
|
|
@ -371,6 +371,22 @@ abstract class ScheduleDao(private val appDatabase: AppDatabase) {
|
|||
ORDER BY e.start_time ASC""")
|
||||
abstract fun getEvents(person: Person): PagingSource<Int, StatusEvent>
|
||||
|
||||
/**
|
||||
* Returns all events.
|
||||
*/
|
||||
@Query("""SELECT e.id , e.start_time, e.end_time, e.room_name, e.slug, et.title, et.subtitle, e.abstract, e.description,
|
||||
GROUP_CONCAT(p.name, ', ') AS persons, e.day_index, d.date AS day_date, e.track_id, t.name AS track_name, t.type AS track_type,
|
||||
b.event_id IS NOT NULL AS is_bookmarked
|
||||
FROM events e JOIN events_titles et ON e.id = et.`rowid`
|
||||
JOIN days d ON e.day_index = d.`index`
|
||||
JOIN tracks t ON e.track_id = t.id
|
||||
LEFT JOIN events_persons ep ON e.id = ep.event_id
|
||||
LEFT JOIN persons p ON ep.person_id = p.`rowid`
|
||||
LEFT JOIN bookmarks b ON e.id = b.event_id
|
||||
GROUP BY e.id
|
||||
ORDER BY e.start_time ASC""")
|
||||
abstract fun getEvents(): PagingSource<Int, StatusEvent>
|
||||
|
||||
/**
|
||||
* Search through matching titles, subtitles, track names, person names.
|
||||
* We need to use an union of 3 sub-queries because a "match" condition can not be
|
||||
|
|
|
@ -46,17 +46,19 @@ class LiveFragment : Fragment(R.layout.fragment_live), RecycledViewPoolProvider
|
|||
|
||||
private val resources = fragment.resources
|
||||
|
||||
override fun getItemCount() = 2
|
||||
override fun getItemCount() = 3
|
||||
|
||||
override fun createFragment(position: Int): Fragment = when (position) {
|
||||
0 -> NextLiveListFragment()
|
||||
1 -> NowLiveListFragment()
|
||||
2 -> AllLiveListFragment()
|
||||
else -> throw IllegalStateException()
|
||||
}
|
||||
|
||||
fun getPageTitle(position: Int): CharSequence? = when (position) {
|
||||
0 -> resources.getString(R.string.next)
|
||||
1 -> resources.getString(R.string.now)
|
||||
2 -> resources.getString(R.string.all)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,3 +91,4 @@ sealed class LiveListFragment(
|
|||
|
||||
class NextLiveListFragment : LiveListFragment(R.string.next_empty, LiveViewModel::nextEvents)
|
||||
class NowLiveListFragment : LiveListFragment(R.string.now_empty, LiveViewModel::eventsInProgress)
|
||||
class AllLiveListFragment : LiveListFragment(R.string.all_empty, LiveViewModel::allEvents)
|
|
@ -57,6 +57,12 @@ class LiveViewModel @Inject constructor(scheduleDao: ScheduleDao) : ViewModel()
|
|||
scheduleDao.getEventsInProgress(now)
|
||||
}
|
||||
|
||||
val allEvents: Flow<PagingData<StatusEvent>> = createLiveEventsHotFlow { now ->
|
||||
scheduleDao.getEvents()
|
||||
}
|
||||
|
||||
|
||||
|
||||
companion object {
|
||||
private val REFRESH_PERIOD = 1.minutes
|
||||
private val NEXT_EVENTS_INTERVAL = Duration.ofHours(3L)
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
</plurals>
|
||||
|
||||
<!-- Live -->
|
||||
<string name="all">All</string>
|
||||
<string name="all_empty">During FOSDEM, all events will be shown here.</string>
|
||||
<string name="next">Next</string>
|
||||
<string name="next_empty">During FOSDEM, the events to come in the next 3 hours will be shown here.</string>
|
||||
<string name="now">Now</string>
|
||||
|
|
Loading…
Reference in a new issue