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){ 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 ):Result{ + private fun downloadGtfsTrips(tripsList: Array): 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 {