Implemented chips for selecting dietary preferences

This commit is contained in:
denizk0461
2023-04-18 10:25:45 +02:00
parent 56cdc4c5ee
commit c385da4287
11 changed files with 299 additions and 24 deletions
@@ -4,6 +4,7 @@ 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.DietaryPreferences
class CanteenViewModel(app: Application) : TemplateViewModel(app) {
@@ -11,8 +12,14 @@ class CanteenViewModel(app: Application) : TemplateViewModel(app) {
val allOffers: LiveData<List<CanteenOffer>> = repo.allOffers
fun getOffersByPreference(): LiveData<List<CanteenOffer>> =
repo.getOffersByPreference()
// fun insertOffers(offers: List<CanteenOffer>) { doAsync { repo.insertOffers(offers) }}
fun nukeOffers() { doAsync { repo.nukeOffers() }}
fun fetchOffers(onFinish: () -> Unit) { doAsync { parser.parse(onFinish) }}
fun fetchOffers(onRefreshUpdate: (status: Int) -> Unit, onFinish: () -> Unit) { doAsync { parser.parse(onRefreshUpdate, onFinish) }}
fun setPreference(pref: DietaryPreferences, newValue: Boolean) { repo.setPreference(pref, newValue) }
fun getPreference(pref: DietaryPreferences): Boolean = repo.getPreference(pref)
}