Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/fragments/LinesViewModel.kt
package it.reyboz.bustorino.fragments | package it.reyboz.bustorino.fragments | ||||
import android.app.Application | import android.app.Application | ||||
import android.util.Log | import android.util.Log | ||||
import androidx.lifecycle.* | import androidx.lifecycle.* | ||||
import it.reyboz.bustorino.backend.Stop | import it.reyboz.bustorino.backend.Stop | ||||
import it.reyboz.bustorino.data.GtfsRepository | import it.reyboz.bustorino.data.GtfsRepository | ||||
import it.reyboz.bustorino.data.NextGenDB | import it.reyboz.bustorino.data.NextGenDB | ||||
import it.reyboz.bustorino.data.OldDataRepository | import it.reyboz.bustorino.data.OldDataRepository | ||||
import it.reyboz.bustorino.data.gtfs.GtfsDatabase | import it.reyboz.bustorino.data.gtfs.GtfsDatabase | ||||
import it.reyboz.bustorino.data.gtfs.GtfsRoute | import it.reyboz.bustorino.data.gtfs.GtfsRoute | ||||
import it.reyboz.bustorino.data.gtfs.MatoPatternWithStops | import it.reyboz.bustorino.data.gtfs.MatoPatternWithStops | ||||
import it.reyboz.bustorino.data.gtfs.PatternStop | |||||
import java.util.concurrent.Executors | import java.util.concurrent.Executors | ||||
class LinesViewModel(application: Application) : AndroidViewModel(application) { | class LinesViewModel(application: Application) : AndroidViewModel(application) { | ||||
private val gtfsRepo: GtfsRepository | private val gtfsRepo: GtfsRepository | ||||
private val oldRepo: OldDataRepository | private val oldRepo: OldDataRepository | ||||
//val patternsByRouteLiveData: LiveData<List<MatoPattern>> | //val patternsByRouteLiveData: LiveData<List<MatoPattern>> | ||||
private val routeIDToSearch = MutableLiveData<String>() | private val routeIDToSearch = MutableLiveData<String>() | ||||
private var lastShownPatternStops = ArrayList<String>() | private var lastShownPatternStops = ArrayList<String>() | ||||
val currentPatternStops = MutableLiveData<List<PatternStop>>() | |||||
val selectedPatternLiveData = MutableLiveData<MatoPatternWithStops>() | |||||
val stopsForPatternLiveData = MutableLiveData<List<Stop>>() | val stopsForPatternLiveData = MutableLiveData<List<Stop>>() | ||||
private val executor = Executors.newFixedThreadPool(2) | private val executor = Executors.newFixedThreadPool(2) | ||||
init { | init { | ||||
val gtfsDao = GtfsDatabase.getGtfsDatabase(application).gtfsDao() | val gtfsDao = GtfsDatabase.getGtfsDatabase(application).gtfsDao() | ||||
gtfsRepo = GtfsRepository(gtfsDao) | gtfsRepo = GtfsRepository(gtfsDao) | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 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