Last active
August 14, 2020 14:38
-
-
Save kevinnls/6463234aab8d431950dba32f8645180e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun getResCards() { | |
val urlAllResCards = "http://13.235.250.119/v2/restaurants/fetch_result/" | |
val queue = Volley.newRequestQueue(activity as Context) | |
val allResCardsReq = object : JsonObjectRequest(Method.GET, urlAllResCards, null, | |
Response.Listener { | |
val response = it.getJSONObject("data") | |
if (response.getString("success") == "true") { | |
val data = response.getJSONArray("data") | |
for (i in 0 until data.length()) { | |
val restJsonObject = data.getJSONObject(i) | |
val restObject = ResEntity( | |
restJsonObject.getString("id"), | |
restJsonObject.getString("name"), | |
restJsonObject.getString("rating"), | |
restJsonObject.getString("cost_for_one"), | |
restJsonObject.getString("image_url") | |
) | |
DBTasks(activity as Context, 40, restObject).execute() | |
if (restObject in resList) | |
continue | |
else | |
resList.add(restObject) | |
} | |
adapter.notifyDataSetChanged() | |
progressLay.visibility = View.GONE | |
} | |
}, | |
Response.ErrorListener { | |
makeToast("vollerr") | |
progressLay.visibility = View.VISIBLE | |
getResCards() | |
}) { | |
override fun getHeaders(): MutableMap<String, String> { | |
val headers = HashMap<String, String>() | |
headers["Content-type"] = "application/json" | |
headers["token"] = "c4d68c99358269" | |
return headers | |
} | |
} | |
queue.add(allResCardsReq) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment