Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2015
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. private List<FbConversation> getFbConversations(String id_field, GenericSqliteHelper helper, final String account) {
  2. if (helper == null) {
  3. if (Cfg.DEBUG) {
  4. Check.log(TAG + " (getFbConversations) Error: null helper");
  5. }
  6. return null;
  7. }
  8.  
  9. final List<FbConversation> conversations = new ArrayList<FbConversation>();
  10.  
  11. // "thread_id"
  12. String[] projection = new String[] { id_field, M.e("participants"), M.e("timestamp_ms") };
  13. String selection = M.e("timestamp_ms > 0 ");
  14.  
  15. RecordVisitor visitor = new RecordVisitor(projection, selection) {
  16.  
  17. @Override
  18. public long cursor(Cursor cursor) {
  19. FbConversation c = new FbConversation();
  20. c.account = account;
  21. c.id = cursor.getString(0);
  22.  
  23. String value = cursor.getString(1);
  24. c.timestamp = cursor.getLong(2);
  25. Contact[] contacts;
  26. try {
  27. contacts = json2Contacts(value);
  28. c.contacts = contacts;
  29. if (Cfg.DEBUG) {
  30. // Check.log(TAG + " (cursor) contacts: " +
  31. // contacts[0].name + " -> " + contacts[1].name);
  32. }
  33. } catch (JSONException e) {
  34. // TODO Auto-generated catch block
  35. e.printStackTrace();
  36. }
  37.  
  38. conversations.add(c);
  39. return 0;
  40. }
  41. };
  42.  
  43. helper.traverseRecords(M.e("threads"), visitor);
  44. return conversations;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement