2023-04-08 17:30:05 +02:00
|
|
|
package com.denizk0461.studip.viewmodel
|
|
|
|
|
|
|
|
|
|
import android.app.Application
|
|
|
|
|
import androidx.lifecycle.LiveData
|
2023-04-08 18:53:51 +02:00
|
|
|
import com.denizk0461.studip.model.StudIPEvent
|
2023-04-08 17:30:05 +02:00
|
|
|
|
2023-04-23 11:57:03 +02:00
|
|
|
/**
|
|
|
|
|
* View model for [com.denizk0461.studip.fragment.EventFragment]
|
|
|
|
|
*
|
|
|
|
|
* @param app reference to the app
|
|
|
|
|
*/
|
2023-04-23 17:13:48 +02:00
|
|
|
class EventViewModel(app: Application) : AppViewModel(app) {
|
2023-04-08 17:30:05 +02:00
|
|
|
|
2023-04-23 11:57:03 +02:00
|
|
|
/**
|
|
|
|
|
* Retrieves all Stud.IP events.
|
|
|
|
|
*
|
|
|
|
|
* @return all Stud.IP events exposed through a LiveData object
|
|
|
|
|
*/
|
2023-04-08 17:30:05 +02:00
|
|
|
val allEvents: LiveData<List<StudIPEvent>> = repo.allEvents
|
2023-04-24 15:43:42 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Updates a schedule element.
|
|
|
|
|
*
|
|
|
|
|
* @param event the event to update
|
|
|
|
|
*/
|
|
|
|
|
fun update(event: StudIPEvent) { doAsync { repo.update(event) } }
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Deletes a schedule element.
|
|
|
|
|
*
|
|
|
|
|
* @param event the event to delete
|
|
|
|
|
*/
|
|
|
|
|
fun delete(event: StudIPEvent) { doAsync { repo.delete(event) } }
|
2023-04-08 17:30:05 +02:00
|
|
|
}
|