ref: motis2_journeys
app/src/main/java/xyz/apiote/bimba/czwek/journeys/JourneysViewModel.kt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
// SPDX-FileCopyrightText: Adam Evyčędo // // SPDX-License-Identifier: GPL-3.0-or-later package xyz.apiote.bimba.czwek.journeys import android.content.Context import android.util.Log import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import kotlinx.coroutines.launch import xyz.apiote.bimba.czwek.repo.Journey import xyz.apiote.bimba.czwek.repo.Place class JourneysViewModel : ViewModel() { private val _journeys = MutableLiveData<List<Journey>>() val journeys: LiveData<List<Journey>> = _journeys fun getJourneys(context: Context, origin: Place, destination: Place) { viewModelScope.launch { Log.i("Journeys", "getting journeys") _journeys.value = xyz.apiote.bimba.czwek.api.getJourney(origin, destination, context) Log.i("Journeys", "got ${journeys.value?.size} journeys") journeys.value?.forEach { Log.i("Journeys", "$it") } } } } |