diff options
author | 2013-08-30 13:48:38 +0700 | |
---|---|---|
committer | 2013-08-30 13:48:38 +0700 | |
commit | 8d1d8d845beb6bc6c99d90722169b77c3dff91e7 (patch) | |
tree | dce92d1d27f94c2c86f130223dcac52763c9e7cc /src/com | |
parent | 40fe707e6566faa02eeba2e8f4830dbbd3992f4a (diff) |
Messages
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/juick/json/Message.java | 12 | ||||
-rw-r--r-- | src/com/juick/json/Messages.java | 27 | ||||
-rw-r--r-- | src/com/juick/json/User.java | 6 | ||||
-rw-r--r-- | src/com/juick/json/Users.java | 2 |
4 files changed, 41 insertions, 6 deletions
diff --git a/src/com/juick/json/Message.java b/src/com/juick/json/Message.java index c1beebc4..18cc375e 100644 --- a/src/com/juick/json/Message.java +++ b/src/com/juick/json/Message.java @@ -83,6 +83,8 @@ public class Message { } if (msg.Timestamp != null) { json.put("timestamp", msg.Timestamp); + } else if (msg.TimestampString != null) { + json.put("timestamp", msg.TimestampString); } if (msg.User != null) { json.put("user", com.juick.json.User.toJSON(msg.User)); @@ -98,16 +100,16 @@ public class Message { } if (msg.AttachmentType != null) { String fname = msg.MID + (msg.RID > 0 ? "-" + msg.RID : "") + "." + msg.AttachmentType; - if (msg.AttachmentType.equals("jpg")) { + if (msg.AttachmentType.equals("mp4")) { + JSONObject video = new JSONObject(); + video.put("mp4", "http://i.juick.com/video/" + fname); + json.put("video", video); + } else { JSONObject photo = new JSONObject(); photo.put("thumbnail", "http://i.juick.com/ps/" + fname); photo.put("small", "http://i.juick.com/photo-512/" + fname); photo.put("medium", "http://i.juick.com/photo-1024/" + fname); json.put("photo", photo); - } else { - JSONObject video = new JSONObject(); - video.put("mp4", "http://i.juick.com/video/" + fname); - json.put("video", video); } } } catch (JSONException e) { diff --git a/src/com/juick/json/Messages.java b/src/com/juick/json/Messages.java new file mode 100644 index 00000000..a1879b09 --- /dev/null +++ b/src/com/juick/json/Messages.java @@ -0,0 +1,27 @@ +package com.juick.json; + +import java.util.ArrayList; +import java.util.Iterator; + +/** + * + * @author ugnich + */ +public class Messages { + + public static String arrayToString(ArrayList<com.juick.Message> messages) { + String json = "["; + + Iterator<com.juick.Message> i = messages.iterator(); + while (i.hasNext()) { + com.juick.Message m = i.next(); + if (json.length() > 1) { + json += ","; + } + json += Message.toJSON(m).toString(); + } + + json += "]"; + return json; + } +} diff --git a/src/com/juick/json/User.java b/src/com/juick/json/User.java index 43ee4803..dd3143c6 100644 --- a/src/com/juick/json/User.java +++ b/src/com/juick/json/User.java @@ -49,6 +49,12 @@ public class User { if (user.FullName != null) { json.put("fullname", user.FullName); } + if (user.JID != null) { + json.put("jid", user.JID); + } + if (user.MessagesCount > 0) { + json.put("MessagesCount", user.MessagesCount); + } } catch (JSONException e) { } diff --git a/src/com/juick/json/Users.java b/src/com/juick/json/Users.java index eda89ccb..0e486f74 100644 --- a/src/com/juick/json/Users.java +++ b/src/com/juick/json/Users.java @@ -22,7 +22,7 @@ public class Users { if (json.length() > 1) { json += ","; } - json += "{\"uid\":" + u.UID + ",\"uname\":\"" + u.UName + "\"}"; + json += User.toJSON(u).toString(); } json += "]"; |