diff options
Diffstat (limited to 'juick-core/src/main/java/com/juick/json')
-rw-r--r-- | juick-core/src/main/java/com/juick/json/JSONSerializer.java | 19 | ||||
-rw-r--r-- | juick-core/src/main/java/com/juick/json/MessageSerializer.java | 7 |
2 files changed, 23 insertions, 3 deletions
diff --git a/juick-core/src/main/java/com/juick/json/JSONSerializer.java b/juick-core/src/main/java/com/juick/json/JSONSerializer.java index 142cacf0..3dc9e04e 100644 --- a/juick-core/src/main/java/com/juick/json/JSONSerializer.java +++ b/juick-core/src/main/java/com/juick/json/JSONSerializer.java @@ -17,6 +17,25 @@ import org.json.JSONObject; */ public abstract class JSONSerializer<T> { + public enum URIScheme { + Plain, + Secure + } + + private URIScheme uriScheme; + + public URIScheme getUriScheme() { + return uriScheme; + } + + public void setUriScheme(URIScheme uriScheme) { + this.uriScheme = uriScheme; + } + + public JSONSerializer() { + this.uriScheme = URIScheme.Plain; + } + /** * * @param json diff --git a/juick-core/src/main/java/com/juick/json/MessageSerializer.java b/juick-core/src/main/java/com/juick/json/MessageSerializer.java index d5adfa6e..9da828c9 100644 --- a/juick-core/src/main/java/com/juick/json/MessageSerializer.java +++ b/juick-core/src/main/java/com/juick/json/MessageSerializer.java @@ -126,9 +126,10 @@ public class MessageSerializer extends JSONSerializer<Message> { if (msg.AttachmentType != null) { String fname = msg.getMID() + (msg.getRID() > 0 ? "-" + msg.getRID() : "") + "." + msg.AttachmentType; JSONObject photo = new JSONObject(); - photo.put("thumbnail", "http://i.juick.com/ps/" + fname); - photo.put("small", "http://i.juick.com/photos-512/" + fname); - photo.put("medium", "http://i.juick.com/photos-1024/" + fname); + String protocol = getUriScheme() == URIScheme.Plain ? "http:" : "https:"; + photo.put("thumbnail", protocol + "//i.juick.com/ps/" + fname); + photo.put("small", protocol + "//i.juick.com/photos-512/" + fname); + photo.put("medium", protocol + "//i.juick.com/photos-1024/" + fname); json.put("photo", photo); } } catch (JSONException e) { |