Archived
Updated EventPageFragment.kt to have access to its own ViewModel and, by extension, its own reference to the database, which forgoes the need to transport data from EventFragment.kt through StudIPEventPageAdapter.kt to EventPageFragment.kt and allows for filtering for a specific day's items through the database rather than needing to iterate through the list via an extension function manually. Also implemented DiffUtil to perform individual updates rather than calling notifyDataSetChanged() every time a single item has been changed.
This commit is contained in:
@@ -21,6 +21,14 @@ interface AppDAO {
|
||||
@get:Query("SELECT * FROM studipevents ORDER BY timeslotId, id")
|
||||
val allEvents: LiveData<List<StudIPEvent>>
|
||||
|
||||
/**
|
||||
* Retrieves Stud.IP events for a specific day, ordered by their timeslots, then their IDs.
|
||||
*
|
||||
* @return Stud.IP events for a certain day exposed through a LiveData object
|
||||
*/
|
||||
@Query("SELECT * FROM studipevents WHERE day = :day ORDER BY timeslotId, id")
|
||||
fun getEventsForDay(day: Int): LiveData<List<StudIPEvent>>
|
||||
|
||||
/**
|
||||
* Updates a given Stud.IP element.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user