Shvet

Untitled

Dec 27th, 2015
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. private void getdatafromfacebook(GraphResponse response) {
  2. JSONObject jsonObject = response.getJSONObject();
  3. arrayList = new ArrayList<>();
  4. if (response.getJSONObject().optJSONArray("data") != null) {
  5.  
  6. next = jsonObject.optJSONObject("paging").optString("next");
  7. previous = jsonObject.optJSONObject("paging").optString("previous");
  8.  
  9. for (int i = 0; i < jsonObject.optJSONArray("data").length(); i++) {
  10. Model model = new Model();
  11. JSONArray sender_data = jsonObject.optJSONArray("data").optJSONObject(i)
  12. .optJSONObject("senders").optJSONArray("data");
  13. for (int z = 0; z < sender_data.length(); z++) {
  14. JSONObject picture_data = sender_data.optJSONObject(z).optJSONObject("picture").optJSONObject("data");
  15. if (!sender_data.optJSONObject(z).optString("id").equals(user_id)) {
  16. model.setPage_conversation_user_id(sender_data.optJSONObject(z).optString("id"));
  17. model.setPage_conversation_user_picture(picture_data.optString("url"));
  18. model.setPage_conversation_user_name(sender_data.optJSONObject(z).optString("name"));
  19. }
  20. }
  21. model.setPage_conversation_id(jsonObject.optJSONArray("data").optJSONObject(i).optString("id"));
  22. model.setPage_conversation_user_message(jsonObject.optJSONArray("data").optJSONObject(i).optString("snippet"));
  23. arrayList.add(model);
  24. }
  25. adapter = new Page_Conversation_List_Adapter(Page_Conversation_list.this, arrayList);
  26. recyclerView.setAdapter(adapter);
  27. adapter.notifyDataSetChanged();
  28. adapter.setOnItemClickListener(this);
  29. } else {
  30. //No Message
  31. }
  32. }
Add Comment
Please, Sign In to add comment