Started implementation of event update sheet

This commit is contained in:
denizk0461
2023-04-24 15:43:42 +02:00
parent a53232a814
commit 9b6e267cb0
24 changed files with 410 additions and 53 deletions
@@ -3,10 +3,7 @@ package com.denizk0461.studip.viewmodel
import android.app.Application
import androidx.lifecycle.LiveData
import com.denizk0461.studip.data.StwParser
import com.denizk0461.studip.model.CanteenOffer
import com.denizk0461.studip.model.DietaryPrefObject
import com.denizk0461.studip.model.DietaryPreferences
import com.denizk0461.studip.model.OfferDate
import com.denizk0461.studip.model.*
/**
* View model for [com.denizk0461.studip.fragment.CanteenFragment]
@@ -66,5 +63,5 @@ class CanteenViewModel(app: Application) : AppViewModel(app) {
* This value determines whether the user wants to have allergens marked.
*/
val preferenceAllergen: Boolean
get() = repo.getPreferenceAllergen()
get() = repo.getPreference(SettingsPreferences.ALLERGEN)
}
@@ -17,4 +17,18 @@ class EventViewModel(app: Application) : AppViewModel(app) {
* @return all Stud.IP events exposed through a LiveData object
*/
val allEvents: LiveData<List<StudIPEvent>> = repo.allEvents
/**
* 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) } }
}
@@ -1,6 +1,7 @@
package com.denizk0461.studip.viewmodel
import android.app.Application
import com.denizk0461.studip.model.SettingsPreferences
/**
* View model for [com.denizk0461.studip.fragment.SettingsFragment]
@@ -9,10 +10,24 @@ import android.app.Application
*/
class SettingsViewModel(app: Application) : AppViewModel(app) {
/**
* This value determines whether the user opts into submitting crash reports.
*/
var preferenceCourseHighlighting: Boolean
get() = repo.getPreference(SettingsPreferences.DATA_HANDLING)
set(newValue) { repo.setPreference(SettingsPreferences.DATA_HANDLING, newValue) }
/**
* This value determines whether the user wants to have allergens marked.
*/
var preferenceAllergen: Boolean
get() = repo.getPreferenceAllergen()
set(value) { repo.setPreferenceAllergen(value) }
get() = repo.getPreference(SettingsPreferences.ALLERGEN)
set(newValue) { repo.setPreference(SettingsPreferences.ALLERGEN, newValue) }
/**
* This value determines whether the user opts into submitting crash reports.
*/
var preferenceDataHandling: Boolean
get() = repo.getPreference(SettingsPreferences.DATA_HANDLING)
set(newValue) { repo.setPreference(SettingsPreferences.DATA_HANDLING, newValue) }
}