Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/backend/mato/VolleyAllStopsRequest.kt
Show All 25 Lines | |||||
import org.json.JSONArray | import org.json.JSONArray | ||||
import org.json.JSONException | import org.json.JSONException | ||||
import org.json.JSONObject | import org.json.JSONObject | ||||
class VolleyAllStopsRequest( | class VolleyAllStopsRequest( | ||||
listener: Response.Listener<List<Palina>>, | listener: Response.Listener<List<Palina>>, | ||||
errorListener: Response.ErrorListener, | errorListener: Response.ErrorListener, | ||||
) : MapiVolleyRequest<List<Palina>>( | ) : MapiVolleyRequest<List<Palina>>( | ||||
MatoAPIFetcher.QueryType.ALL_STOPS,listener, errorListener) { | MatoQueries.QueryType.ALL_STOPS,listener, errorListener) { | ||||
private val FEEDS = JSONArray() | private val FEEDS = JSONArray() | ||||
init { | init { | ||||
FEEDS.put("gtt") | FEEDS.put("gtt") | ||||
} | } | ||||
override fun getBody(): ByteArray { | override fun getBody(): ByteArray { | ||||
val variables = JSONObject() | val variables = JSONObject() | ||||
variables.put("feeds", FEEDS) | variables.put("feeds", FEEDS) | ||||
Show All 25 Lines | override fun parseNetworkResponse(response: NetworkResponse?): Response<List<Palina>> { | ||||
Log.e("VolleyBusTO","Cannot parse response as JSON") | Log.e("VolleyBusTO","Cannot parse response as JSON") | ||||
e.printStackTrace() | e.printStackTrace() | ||||
return Response.error(VolleyError("Error parsing JSON")) | return Response.error(VolleyError("Error parsing JSON")) | ||||
} | } | ||||
return Response.success(palinas, HttpHeaderParser.parseCacheHeaders(response)) | return Response.success(palinas, HttpHeaderParser.parseCacheHeaders(response)) | ||||
} | } | ||||
companion object{ | companion object{ | ||||
val FEEDS_STR = arrayOf("gtt") | //val FEEDS_STR = arrayOf("gtt") | ||||
} | } | ||||
} | } | ||||
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