Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/fragments/LinesViewModel.kt
Show All 40 Lines | class LinesViewModel(application: Application) : AndroidViewModel(application) { | ||||
val routesName: LiveData<List<String>> = Transformations.map(routesGTTLiveData) { | val routesName: LiveData<List<String>> = Transformations.map(routesGTTLiveData) { | ||||
it.map { route -> route.longName } | it.map { route -> route.longName } | ||||
} | } | ||||
fun setRouteIDQuery(routeID: String){ | fun setRouteIDQuery(routeID: String){ | ||||
routeIDToSearch.value = routeID | routeIDToSearch.value = routeID | ||||
} | } | ||||
fun getRouteIDQueried(): String?{ | |||||
return routeIDToSearch.value | |||||
} | |||||
var shouldShowMessage = true; | |||||
fun requestStopsForGTFSIDs(gtfsIDs: List<String>){ | fun requestStopsForGTFSIDs(gtfsIDs: List<String>){ | ||||
oldRepo.requestStopsWithGtfsIDs(gtfsIDs) { | oldRepo.requestStopsWithGtfsIDs(gtfsIDs) { | ||||
if (it.isSuccess) { | if (it.isSuccess) { | ||||
stopsForPatternLiveData.postValue(it.result) | stopsForPatternLiveData.postValue(it.result) | ||||
} else { | } else { | ||||
Log.e("BusTO-LinesVM", "Got error on callback with stops for gtfsID") | Log.e("BusTO-LinesVM", "Got error on callback with stops for gtfsID") | ||||
it.exception?.printStackTrace() | it.exception?.printStackTrace() | ||||
} | } | ||||
Show All 13 Lines | /*fun getLinesGTT(): MutableLiveData<List<GtfsRoute>> { | ||||
val routesData = MutableLiveData<List<GtfsRoute>>() | val routesData = MutableLiveData<List<GtfsRoute>>() | ||||
viewModelScope.launch { | viewModelScope.launch { | ||||
val routes=gtfsRepo.getLinesForFeed("gtt") | val routes=gtfsRepo.getLinesForFeed("gtt") | ||||
routesData.postValue(routes) | routesData.postValue(routes) | ||||
} | } | ||||
return routesData | return routesData | ||||
}*/ | }*/ | ||||
} | } | ||||
No newline at end of file | No newline at end of file |
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register