aboutsummaryrefslogtreecommitdiff
path: root/juick-core
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-11-30 16:49:11 +0300
committerGravatar Vitaly Takmazov2016-11-30 16:49:11 +0300
commit1a2830588131173d8fbfeb1fe03c466b4cf30e46 (patch)
tree53889640b356f22e6620acffed0bda1e56babcf6 /juick-core
parentf5fd9c7bea380eb4c0c2d58f2167ad3f07c45c33 (diff)
juick-core: fix attachment serialization
Diffstat (limited to 'juick-core')
-rw-r--r--juick-core/src/main/java/com/juick/Message.java33
-rw-r--r--juick-core/src/main/java/com/juick/Photo.java34
-rw-r--r--juick-core/src/main/java/com/juick/formatters/PlainTextFormatter.java4
3 files changed, 62 insertions, 9 deletions
diff --git a/juick-core/src/main/java/com/juick/Message.java b/juick-core/src/main/java/com/juick/Message.java
index b5fc2b89..d3f28e22 100644
--- a/juick-core/src/main/java/com/juick/Message.java
+++ b/juick-core/src/main/java/com/juick/Message.java
@@ -57,9 +57,9 @@ public class Message implements Comparable {
@XmlTransient
public int Replies = 0;
public String RepliesBy = null;
+ private String attachmentType;
@XmlTransient
- public String AttachmentType = null;
- public String Photo = null;
+ private Photo photo;
public String Video = null;
public Place Place = null;
@XmlTransient
@@ -87,8 +87,8 @@ public class Message implements Comparable {
ReadOnly = msg.ReadOnly;
Hidden = msg.Hidden;
Replies = msg.Replies;
- AttachmentType = msg.AttachmentType;
- Photo = msg.Photo;
+ attachmentType = msg.attachmentType;
+ photo = msg.photo;
Video = msg.Video;
Place = msg.Place;
Likes = msg.Likes;
@@ -157,15 +157,16 @@ public class Message implements Comparable {
}
}
+ @JsonIgnore
public String getAttachmentURL() {
- if (AttachmentType != null) {
+ if (attachmentType != null) {
String url = "http://i.juick.com/";
- url += AttachmentType.equals("mp4") ? "video" : "photos-1024";
+ url += attachmentType.equals("mp4") ? "video" : "photos-1024";
url += "/" + getMid();
if (getRid() > 0) {
url += "-" + getRid();
}
- url += "." + AttachmentType;
+ url += "." + attachmentType;
return url;
} else {
return null;
@@ -309,4 +310,22 @@ public class Message implements Comparable {
public void setPrivacy(int privacy) {
this.privacy = privacy;
}
+
+ public Photo getPhoto() {
+ return photo;
+ }
+
+ public void setPhoto(Photo photo) {
+ this.photo = photo;
+ }
+
+ @XmlAttribute(name = "attach")
+ @JsonProperty("attach")
+ public String getAttachmentType() {
+ return attachmentType;
+ }
+
+ public void setAttachmentType(String attachmentType) {
+ this.attachmentType = attachmentType;
+ }
}
diff --git a/juick-core/src/main/java/com/juick/Photo.java b/juick-core/src/main/java/com/juick/Photo.java
new file mode 100644
index 00000000..010d81a4
--- /dev/null
+++ b/juick-core/src/main/java/com/juick/Photo.java
@@ -0,0 +1,34 @@
+package com.juick;
+
+/**
+ * Created by vitalyster on 30.11.2016.
+ */
+public class Photo {
+ private String small;
+ private String medium;
+ private String thumbnail;
+
+ public String getSmall() {
+ return small;
+ }
+
+ public void setSmall(String small) {
+ this.small = small;
+ }
+
+ public String getMedium() {
+ return medium;
+ }
+
+ public void setMedium(String medium) {
+ this.medium = medium;
+ }
+
+ public String getThumbnail() {
+ return thumbnail;
+ }
+
+ public void setThumbnail(String thumbnail) {
+ this.thumbnail = thumbnail;
+ }
+}
diff --git a/juick-core/src/main/java/com/juick/formatters/PlainTextFormatter.java b/juick-core/src/main/java/com/juick/formatters/PlainTextFormatter.java
index be2c6838..c6e9022a 100644
--- a/juick-core/src/main/java/com/juick/formatters/PlainTextFormatter.java
+++ b/juick-core/src/main/java/com/juick/formatters/PlainTextFormatter.java
@@ -11,8 +11,8 @@ public class PlainTextFormatter {
String subtitle = isReply ? jmsg.getReplyQuote() : jmsg.getTagsString();
sb.append(title).append(jmsg.getUser().getName()).append(":\n")
.append(subtitle).append("\n").append(jmsg.getText()).append("\n");
- if (jmsg.Photo != null) {
- sb.append(jmsg.Photo);
+ if (jmsg.getPhoto() != null) {
+ sb.append(jmsg.getAttachmentURL());
}
return sb.toString();
}