diff options
Diffstat (limited to 'juick-core/src/main')
4 files changed, 70 insertions, 42 deletions
diff --git a/juick-core/src/main/java/com/juick/Attachment.java b/juick-core/src/main/java/com/juick/Attachment.java new file mode 100644 index 00000000..76f2995a --- /dev/null +++ b/juick-core/src/main/java/com/juick/Attachment.java @@ -0,0 +1,58 @@ +package com.juick; + +public class Attachment { + private String url; + private Integer height; + private Integer width; + private Attachment small; + private Attachment medium; + private Attachment thumbnail; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public Integer getHeight() { + return height; + } + + public void setHeight(Integer height) { + this.height = height; + } + + public Integer getWidth() { + return width; + } + + public void setWidth(Integer width) { + this.width = width; + } + + public Attachment getSmall() { + return small; + } + + public void setSmall(Attachment small) { + this.small = small; + } + + public Attachment getMedium() { + return medium; + } + + public void setMedium(Attachment medium) { + this.medium = medium; + } + + public Attachment getThumbnail() { + return thumbnail; + } + + public void setThumbnail(Attachment thumbnail) { + this.thumbnail = thumbnail; + } +} diff --git a/juick-core/src/main/java/com/juick/Message.java b/juick-core/src/main/java/com/juick/Message.java index 25463c46..8f903e1f 100644 --- a/juick-core/src/main/java/com/juick/Message.java +++ b/juick-core/src/main/java/com/juick/Message.java @@ -27,16 +27,13 @@ import org.apache.commons.lang3.builder.ToStringBuilder; import javax.xml.bind.annotation.*; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import java.time.Instant; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; -import java.util.TreeSet; +import java.util.*; /** * @author Ugnich Anton */ @XmlRootElement(name = "juick", namespace = "http://juick.com/message") -@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER) +@XmlAccessorType() public class Message implements Comparable { private int mid = 0; private int rid = 0; @@ -67,6 +64,8 @@ public class Message implements Comparable { private String attachmentType; @XmlTransient private Photo photo; + @XmlTransient + private Attachment attachment; public String Video = null; public Place Place = null; private int likes; @@ -159,25 +158,6 @@ public class Message implements Comparable { } @JsonIgnore - public String getAttachmentURL() { - if (attachmentType != null) { - StringBuilder builder = new StringBuilder(); - - builder.append("http://i.juick.com/"); - builder.append(attachmentType.equals("mp4") ? "video" : "photos-1024"); - builder.append("/").append(getMid()); - - if (getRid() > 0) - builder.append("-").append(getRid()); - - builder.append(".").append(attachmentType); - - return builder.toString(); - } - return null; - } - - @JsonIgnore public String getTagsString() { StringBuilder builder = new StringBuilder(); if (!tags.isEmpty()) { @@ -352,22 +332,10 @@ public class Message implements Comparable { this.repliesBy = repliesBy; } - @JsonProperty("photo") - @XmlTransient - public Photo getPhotoURLs() { - if (StringUtils.isNotBlank(attachmentType)) { - Photo photo = new Photo(); - if (rid > 0) { - photo.setSmall(String.format("https://i.juick.com/photos-512/%d-%d.%s", mid, rid, attachmentType)); - photo.setMedium(String.format("https://i.juick.com/photos-1024/%d-%d.%s", mid, rid, attachmentType)); - photo.setThumbnail(String.format("https://i.juick.com/ps/%d-%d.%s", mid, rid, attachmentType)); - } else { - photo.setSmall(String.format("https://i.juick.com/photos-512/%d.%s", mid, attachmentType)); - photo.setMedium(String.format("https://i.juick.com/photos-1024/%d.%s", mid, attachmentType)); - photo.setThumbnail(String.format("https://i.juick.com/ps/%d.%s", mid, attachmentType)); - } - return photo; - } - return null; + public Attachment getAttachment() { + return attachment; + } + public void setAttachment(Attachment attachment) { + this.attachment = attachment; } } diff --git a/juick-core/src/main/java/com/juick/Photo.java b/juick-core/src/main/java/com/juick/Photo.java index af20fc88..06299610 100644 --- a/juick-core/src/main/java/com/juick/Photo.java +++ b/juick-core/src/main/java/com/juick/Photo.java @@ -20,6 +20,8 @@ package com.juick; /** * Created by vitalyster on 30.11.2016. */ +// used for compatibility +@Deprecated public class Photo { private String small; private String medium; 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 c62e0134..06ae8a0a 100644 --- a/juick-core/src/main/java/com/juick/formatters/PlainTextFormatter.java +++ b/juick-core/src/main/java/com/juick/formatters/PlainTextFormatter.java @@ -39,7 +39,7 @@ public class PlainTextFormatter { sb.append(title).append(jmsg.getUser().getName()).append(":\n") .append(subtitle).append("\n").append(jmsg.getText()).append("\n"); if (jmsg.getPhoto() != null) { - sb.append(jmsg.getAttachmentURL()); + sb.append(jmsg.getAttachment().getMedium().getUrl()); } return sb.toString(); } |