Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/backend/mato/MatoAPIFetcher.kt
Show First 20 Lines • Show All 118 Lines • ▼ Show 20 Lines | companion object{ | ||||
val requestQueue = NetworkVolleyManager.getInstance(context).requestQueue | val requestQueue = NetworkVolleyManager.getInstance(context).requestQueue | ||||
val future = RequestFuture.newFuture<List<Palina>>() | val future = RequestFuture.newFuture<List<Palina>>() | ||||
val request = VolleyAllStopsRequest(future, future) | val request = VolleyAllStopsRequest(future, future) | ||||
request.tag = getVolleyReqTag(QueryType.ALL_STOPS) | request.tag = getVolleyReqTag(QueryType.ALL_STOPS) | ||||
requestQueue.add(request) | requestQueue.add(request) | ||||
var palinaList:List<Palina> = mutableListOf<Palina>() | var palinaList:List<Palina> = mutableListOf() | ||||
try { | try { | ||||
palinaList = future.get(30, TimeUnit.SECONDS) | palinaList = future.get(60, TimeUnit.SECONDS) | ||||
res?.set(Fetcher.Result.OK) | res?.set(Fetcher.Result.OK) | ||||
}catch (e: InterruptedException) { | }catch (e: InterruptedException) { | ||||
e.printStackTrace() | e.printStackTrace() | ||||
res?.set(Fetcher.Result.PARSER_ERROR) | res?.set(Fetcher.Result.PARSER_ERROR) | ||||
} catch (e: ExecutionException) { | } catch (e: ExecutionException) { | ||||
e.printStackTrace() | e.printStackTrace() | ||||
res?.set(Fetcher.Result.SERVER_ERROR) | res?.set(Fetcher.Result.SERVER_ERROR) | ||||
▲ Show 20 Lines • Show All 122 Lines • ▼ Show 20 Lines | open class MatoAPIFetcher(val minNumPassaggi: Int) : ArrivalsFetcher { | ||||
} | } | ||||
enum class QueryType { | enum class QueryType { | ||||
ARRIVALS, ALL_STOPS | ARRIVALS, ALL_STOPS | ||||
} | } | ||||
} | } | ||||
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