diff options
author | Vitaly Takmazov | 2016-07-14 12:10:17 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2016-07-14 12:10:17 +0300 |
commit | d8af0bae55e6d32440cd9faa65674a0ae239968e (patch) | |
tree | db95a4541f1524f498281a1dc54b0873403e1616 /juick-core/src/main/java/com/juick/json | |
parent | f04b1c21e42525377d01b5d102006ae4efe5d4b1 (diff) |
JSON: read X-Scheme header to set urls scheme, SQL queries refactoring
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) { |