Page MenuHomeGitPull.it

D216.1773637947.diff
No OneTemporary

Size
4 KB
Referenced Files
None
Subscribers
None

D216.1773637947.diff

diff --git a/app/src/main/java/it/reyboz/bustorino/data/MatoRepository.kt b/app/src/main/java/it/reyboz/bustorino/data/MatoRepository.kt
--- a/app/src/main/java/it/reyboz/bustorino/data/MatoRepository.kt
+++ b/app/src/main/java/it/reyboz/bustorino/data/MatoRepository.kt
@@ -35,7 +35,7 @@
fun requestTripUpdate(tripId: String, errorListener: Response.ErrorListener?, callback: Callback<GtfsTrip>){
val params = JSONObject()
params.put("field",tripId)
- Log.i(DEBUG_TAG, "Requesting info for trip id: $tripId")
+ Log.d(DEBUG_TAG, "Requesting info for trip id: $tripId")
netVolleyManager.addToRequestQueue(MatoVolleyJSONRequest(
MatoQueries.QueryType.TRIP,params,{
try {
diff --git a/app/src/main/java/it/reyboz/bustorino/data/MatoTripsDownloadWorker.kt b/app/src/main/java/it/reyboz/bustorino/data/MatoTripsDownloadWorker.kt
--- a/app/src/main/java/it/reyboz/bustorino/data/MatoTripsDownloadWorker.kt
+++ b/app/src/main/java/it/reyboz/bustorino/data/MatoTripsDownloadWorker.kt
@@ -25,6 +25,7 @@
import it.reyboz.bustorino.backend.Notifications
import it.reyboz.bustorino.data.gtfs.GtfsTrip
import java.util.concurrent.CountDownLatch
+import kotlin.math.min
class MatoTripsDownloadWorker(appContext: Context, workerParams: WorkerParameters)
: CoroutineWorker(appContext, workerParams) {
@@ -37,13 +38,26 @@
Log.e(DEBUG_TAG,"trips list given is null")
return Result.failure()
}
- return downloadGtfsTrips(tripsList!!)
+ val numTrips = tripsList.size
+ var i = 0
+ var totDown = 0
+ while (i <numTrips){
+ val res = downloadGtfsTrips(tripsList.copyOfRange(i, min(i+100, numTrips)))
+ if (res < 0){
+ return Result.failure();
+ }
+ totDown += res
+ Log.d("MatoTripsDownloadWorker", "Downloaded ${res} trips")
+
+ i+= 100
+ }
+ return Result.success(Data.Builder().putInt("tripsDownloaded", totDown).build())
}
/**
* Download GTFS Trips from Mato
*/
- private fun downloadGtfsTrips(tripsList: Array<String>):Result{
+ private fun downloadGtfsTrips(tripsList: Array<String>): Int{
val gtfsRepository = GtfsRepository(applicationContext)
val matoRepository = MatoRepository(applicationContext)
@@ -88,7 +102,7 @@
matoRepository.clearVolleyCache()
if (tripsIDsCompleted.isEmpty()){
Log.d(DEBUG_TAG, "No trips have been downloaded, set work to fail")
- return Result.failure()
+ return -5
} else {
val doInsert = (queriedMatoTrips subtract failedMatoTripsDownload).containsAll(tripsIDsCompleted)
Log.i(DEBUG_TAG, "Inserting missing GtfsTrips in the database, should insert $doInsert")
@@ -98,7 +112,7 @@
}
- return Result.success()
+ return downloadedMatoTrips.size
}
}
override suspend fun getForegroundInfo(): ForegroundInfo {
diff --git a/app/src/main/java/it/reyboz/bustorino/fragments/GeneralMapLibreFragment.kt b/app/src/main/java/it/reyboz/bustorino/fragments/GeneralMapLibreFragment.kt
--- a/app/src/main/java/it/reyboz/bustorino/fragments/GeneralMapLibreFragment.kt
+++ b/app/src/main/java/it/reyboz/bustorino/fragments/GeneralMapLibreFragment.kt
@@ -687,7 +687,14 @@
}
protected fun initStopsLayer(style: Style, stopsFeatures: FeatureCollection?){
- initStopsLayer(style, stopsFeatures,"symbol-transit-airfield" )
+ //determine default layer
+ var layerAbove = ""
+ if (lastMapStyle == MapLibreUtils.STYLE_OSM_RASTER){
+ layerAbove = "osm-raster"
+ } else if (lastMapStyle == MapLibreUtils.STYLE_VECTOR){
+ layerAbove = "symbol-transit-airfield"
+ }
+ initStopsLayer(style, stopsFeatures, layerAbove)
}
protected fun initStopsLayer(style: Style, stopsFeatures: FeatureCollection?, stopsLayerAbove: String){
diff --git a/app/src/main/java/it/reyboz/bustorino/map/MapLibreUtils.kt b/app/src/main/java/it/reyboz/bustorino/map/MapLibreUtils.kt
--- a/app/src/main/java/it/reyboz/bustorino/map/MapLibreUtils.kt
+++ b/app/src/main/java/it/reyboz/bustorino/map/MapLibreUtils.kt
@@ -16,13 +16,15 @@
class MapLibreUtils {
companion object{
- const val STYLE_BRIGHT_DEFAULT_JSON = "map_style_good_noshops.json"
+ //const val STYLE_BRIGHT_DEFAULT_JSON = "map_style_good_noshops.json"
const val STYLE_VERSATILES_COLORFUL_JSON = "versatiles_colorful_light.json"
const val STYLE_OSM_RASTER="openstreetmap_raster.json"
+
+ const val STYLE_VECTOR = STYLE_VERSATILES_COLORFUL_JSON
private const val DEBUG_TAG ="BusTO-MapLibreUtils"
@JvmStatic
- fun getDefaultStyleJson() = STYLE_VERSATILES_COLORFUL_JSON
+ fun getDefaultStyleJson() = STYLE_VECTOR
@JvmStatic
fun shortestRotation(from: Float, to: Float): Float {

File Metadata

Mime Type
text/plain
Expires
Mon, Mar 16, 06:12 (13 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1750881
Default Alt Text
D216.1773637947.diff (4 KB)

Event Timeline