Archived
Started implementation of event update sheet
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
package com.denizk0461.studip.db
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Insert
|
||||
import androidx.room.Query
|
||||
import androidx.room.*
|
||||
import com.denizk0461.studip.model.*
|
||||
|
||||
/**
|
||||
@@ -16,13 +14,29 @@ interface AppDAO {
|
||||
/* --- Stud.IP schedule events --- */
|
||||
|
||||
/**
|
||||
* Retrieves all Stud.IP events.
|
||||
* Retrieves all Stud.IP events, ordered by their timeslots, then their IDs.
|
||||
*
|
||||
* @return all Stud.IP events exposed through a LiveData object
|
||||
*/
|
||||
@get:Query("SELECT * FROM events ORDER BY id")
|
||||
@get:Query("SELECT * FROM events ORDER BY timeslotId, id")
|
||||
val allEvents: LiveData<List<StudIPEvent>>
|
||||
|
||||
/**
|
||||
* Updates a given Stud.IP element.
|
||||
*
|
||||
* @param event object to be updated
|
||||
*/
|
||||
@Update
|
||||
fun update(event: StudIPEvent)
|
||||
|
||||
/**
|
||||
* Updates a given Stud.IP element.
|
||||
*
|
||||
* @param event object to be updated
|
||||
*/
|
||||
@Delete
|
||||
fun delete(event: StudIPEvent)
|
||||
|
||||
/**
|
||||
* Inserts a Stud.IP event into the database.
|
||||
*
|
||||
|
||||
@@ -17,7 +17,7 @@ import com.denizk0461.studip.model.*
|
||||
OfferCategory::class,
|
||||
OfferItem::class
|
||||
],
|
||||
version = 12,
|
||||
version = 13,
|
||||
)
|
||||
abstract class AppDatabase : RoomDatabase() {
|
||||
|
||||
|
||||
@@ -51,6 +51,24 @@ class AppRepository(app: Application) {
|
||||
*/
|
||||
val allOffers: LiveData<List<CanteenOffer>> = dao.allOffers
|
||||
|
||||
/**
|
||||
* Updates a schedule element.
|
||||
*
|
||||
* @param event the event to update
|
||||
*/
|
||||
fun update(event: StudIPEvent) {
|
||||
dao.update(event)
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a schedule element.
|
||||
*
|
||||
* @param event the event to delete
|
||||
*/
|
||||
fun delete(event: StudIPEvent) {
|
||||
dao.delete(event)
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves all canteen offer date objects.
|
||||
*
|
||||
@@ -147,18 +165,20 @@ class AppRepository(app: Application) {
|
||||
// --- settings preferences --- //
|
||||
|
||||
/**
|
||||
* Retrieves the user's preference on displaying allergens.
|
||||
* Retrieves ta user-set boolean preference.
|
||||
*
|
||||
* @return whether the user set this preference
|
||||
* @param pref preference to retrieve
|
||||
* @return whether the user set this preference
|
||||
*/
|
||||
fun getPreferenceAllergen(): Boolean = prefs.getBoolean("setting_allergen", false)
|
||||
fun getPreference(pref: SettingsPreferences): Boolean = prefs.getBoolean(pref.key, false)
|
||||
|
||||
/**
|
||||
* Updates the user's preference on displaying allergens.
|
||||
* Updates a user-set boolean preference.
|
||||
*
|
||||
* @param value new value to set the preference to
|
||||
* @param pref preference to set
|
||||
* @param newValue new value to set the preference to
|
||||
*/
|
||||
fun setPreferenceAllergen(value: Boolean) {
|
||||
prefs.edit().putBoolean("setting_allergen", value).apply()
|
||||
fun setPreference(pref: SettingsPreferences, newValue: Boolean) {
|
||||
prefs.edit().putBoolean(pref.key, newValue).apply()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user