Created
August 13, 2020 11:34
-
-
Save Ochornma/a8c2e9da7a8a677f98c8871d529d0304 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
| fun jsonParseMessage(languageID: Int) { | |
| var id = 0 | |
| val onDemands: MutableList<Message> = ArrayList<Message>() | |
| val request: JsonObjectRequest = object : | |
| JsonObjectRequest(Method.GET, | |
| "https://api.dclmict.org/v1/sermon/data", | |
| null, | |
| Response.Listener { response: JSONObject -> | |
| try { | |
| val `object` = response.getJSONObject("meta") | |
| var count = `object`.getString("count").toInt() | |
| for (i in 0..25) { | |
| val object2 = response.getJSONObject("result") | |
| val object3 = object2.getJSONObject("data") | |
| try { | |
| val object4 = object3.getJSONObject(count.toString()) | |
| val sermonTitle = object4.getString("sermonTitle") | |
| val date = object4.getString("sermonDate") | |
| val sermonLow = object4.getString("sermonLow") | |
| val sermonHigh = object4.getString("sermonHigh") | |
| val sermonAudio = object4.getString("sermonAudio") | |
| val languageId = object4.getInt("languageId") | |
| val category = object4.getInt("categoryId") | |
| val outline = object4.getString("bibleText") | |
| val pdf = object4.getString("sermonYoutubeFre") | |
| val doc = object4.getString("sermonYoutubeEng") | |
| if (languageId == languageID) { | |
| if (languageId == 1) { | |
| onDemands.add( | |
| Message( | |
| title = sermonTitle, | |
| audio = sermonAudio, | |
| video = sermonLow, | |
| preacher = context.resources.getString(R.string.kumuyi), | |
| duration = categories[category - 1].category, | |
| id = id, | |
| doc = doc, | |
| pdf = pdf, | |
| outline = outline | |
| ) | |
| ) | |
| id += 1 | |
| } else { | |
| onDemands.add( | |
| Message( | |
| title = sermonTitle, | |
| audio = sermonAudio, | |
| video = sermonHigh, | |
| preacher = context.resources.getString(R.string.kumuyi), | |
| duration = categories[category - 1].category, | |
| id = id, | |
| doc = doc, | |
| pdf = pdf, | |
| outline = outline | |
| ) | |
| ) | |
| id += 1 | |
| } | |
| } | |
| } catch (E: JSONException) { | |
| E.printStackTrace() | |
| } | |
| count-- | |
| //Log.i(" count", date); | |
| } | |
| } catch (e: JSONException) { | |
| e.printStackTrace() | |
| } | |
| messageRecieved.recieved(onDemands) | |
| }, | |
| Response.ErrorListener { | |
| messageRecieved.error() | |
| } | |
| ) { | |
| } | |
| mQueue!!.add(request) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment