pzy64X

POST-KOTLIN

Sep 28th, 2018
765
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1.  
  2. val formBody = FormBody.Builder()
  3. .add("group", group.text.toString())
  4. .add("description", description.text.toString())
  5. .add("category", arguments?.getString("id", "null"))
  6. .build()
  7.  
  8. val request = Request.Builder()
  9. .url("http://192.168.100.70:3000/amigosApi/grp/group/")
  10. .post(formBody)
  11. .build()
  12.  
  13. val client = OkHttpClient()
  14.  
  15. val response = client.newCall(request).execute()
  16.  
  17. response.body()?.let {
  18. val responseString = it.string()
  19. Log.d("xtx", responseString)
  20. Log.d("xtx", group.text.toString())
  21. Log.d("xtx", description.text.toString())
  22. uiThread {
  23. if (responseString.contains("200")) {
  24. ctx?.toast("Sucessful")
  25. dismiss()
  26. } else {
  27. ctx?.toast("Entry failed")
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment