|
@@ -1,9 +1,12 @@
|
|
|
package com.core.model;
|
|
package com.core.model;
|
|
|
|
|
|
|
|
|
|
+import android.support.annotation.IntDef;
|
|
|
|
|
+
|
|
|
import com.common.data.DateFormatUtil;
|
|
import com.common.data.DateFormatUtil;
|
|
|
import com.common.data.JSONUtil;
|
|
import com.common.data.JSONUtil;
|
|
|
-import com.common.data.StringUtil;
|
|
|
|
|
|
|
|
|
|
|
|
+import java.lang.annotation.Retention;
|
|
|
|
|
+import java.lang.annotation.RetentionPolicy;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
|
@@ -12,30 +15,29 @@ import java.util.Map;
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
public class UUHelperModel {
|
|
public class UUHelperModel {
|
|
|
|
|
+ public static final int ARTICLE_SINGLE = 1, ARTICLE_MERGE = 2;
|
|
|
|
|
|
|
|
- private boolean isTag;
|
|
|
|
|
private int id;
|
|
private int id;
|
|
|
|
|
+ private int type;
|
|
|
private long timeSend;//发送时间
|
|
private long timeSend;//发送时间
|
|
|
private String date;//发送日期(通过timeSend)
|
|
private String date;//发送日期(通过timeSend)
|
|
|
|
|
+
|
|
|
|
|
+ private String title;
|
|
|
|
|
+ private String content;//显示内容
|
|
|
private String imageUrl;//图片网址
|
|
private String imageUrl;//图片网址
|
|
|
private String linkUrl;//链接网址
|
|
private String linkUrl;//链接网址
|
|
|
private String iconUrl;//小图片网址
|
|
private String iconUrl;//小图片网址
|
|
|
- private String content;//显示内容
|
|
|
|
|
private boolean readed;
|
|
private boolean readed;
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public String toString() {
|
|
public String toString() {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("isTag", isTag);
|
|
|
|
|
map.put("_id", id);
|
|
map.put("_id", id);
|
|
|
- map.put("timeSend", timeSend);
|
|
|
|
|
|
|
+ map.put("type", type);
|
|
|
|
|
+ map.put("title", title);
|
|
|
map.put("date", date);
|
|
map.put("date", date);
|
|
|
|
|
+ map.put("timeSend", timeSend);
|
|
|
map.put("imageUrl", imageUrl);
|
|
map.put("imageUrl", imageUrl);
|
|
|
map.put("linkUrl", linkUrl);
|
|
map.put("linkUrl", linkUrl);
|
|
|
map.put("iconUrl", iconUrl);
|
|
map.put("iconUrl", iconUrl);
|
|
@@ -43,37 +45,67 @@ public class UUHelperModel {
|
|
|
return JSONUtil.map2JSON(map);
|
|
return JSONUtil.map2JSON(map);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public UUHelperModel(String date) {
|
|
|
|
|
- this.isTag = true;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /*通过数据源获取到数据封装成类*/
|
|
|
|
|
+ public UUHelperModel(long timeSend) {
|
|
|
|
|
+ this(timeSend, DateFormatUtil.long2Str(timeSend, DateFormatUtil.YMD_HMS), ARTICLE_SINGLE);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /*数据库获取到的数据封装成类*/
|
|
|
|
|
+ public UUHelperModel(long timeSend, String date, int type) {
|
|
|
|
|
+ this.timeSend = timeSend;
|
|
|
this.date = date;
|
|
this.date = date;
|
|
|
|
|
+ this.type = type;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public UUHelperModel(long timeSend,
|
|
|
|
|
- String imageUrl,
|
|
|
|
|
- String iconUrl,
|
|
|
|
|
- String linkUrl,
|
|
|
|
|
- String content) {
|
|
|
|
|
- this(false, 0, timeSend, imageUrl, iconUrl, linkUrl, content, null);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ public UUHelperModel setId(int id) {
|
|
|
|
|
+ this.id = id;
|
|
|
|
|
+ return this;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public UUHelperModel(boolean readed, int _id, long timeSend,
|
|
|
|
|
- String imageUrl,
|
|
|
|
|
- String iconUrl,
|
|
|
|
|
- String linkUrl,
|
|
|
|
|
- String content
|
|
|
|
|
- , String date) {
|
|
|
|
|
- this.readed = readed;
|
|
|
|
|
- this.id = _id;
|
|
|
|
|
- this.timeSend = timeSend;
|
|
|
|
|
|
|
+ public UUHelperModel setType(@Duration int type) {
|
|
|
|
|
+ this.type = type;
|
|
|
|
|
+ return this;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public UUHelperModel setTitle(String title) {
|
|
|
|
|
+ this.title = title;
|
|
|
|
|
+ return this;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public UUHelperModel setContent(String content) {
|
|
|
|
|
+ this.content = content;
|
|
|
|
|
+ return this;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public UUHelperModel setImageUrl(String imageUrl) {
|
|
|
this.imageUrl = imageUrl;
|
|
this.imageUrl = imageUrl;
|
|
|
- this.iconUrl = iconUrl;
|
|
|
|
|
|
|
+ return this;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public UUHelperModel setLinkUrl(String linkUrl) {
|
|
|
this.linkUrl = linkUrl;
|
|
this.linkUrl = linkUrl;
|
|
|
- this.content = content;
|
|
|
|
|
- if (StringUtil.isEmpty(date)) {
|
|
|
|
|
- this.date = DateFormatUtil.long2Str(this.timeSend, DateFormatUtil.YMD);
|
|
|
|
|
- } else {
|
|
|
|
|
- this.date = date;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ return this;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public UUHelperModel setIconUrl(String iconUrl) {
|
|
|
|
|
+ this.iconUrl = iconUrl;
|
|
|
|
|
+ return this;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public UUHelperModel setReaded(boolean readed) {
|
|
|
|
|
+ this.readed = readed;
|
|
|
|
|
+ return this;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ public int getId() {
|
|
|
|
|
+ return id;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public int getType() {
|
|
|
|
|
+ return type;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public long getTimeSend() {
|
|
public long getTimeSend() {
|
|
@@ -81,34 +113,39 @@ public class UUHelperModel {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public String getDate() {
|
|
public String getDate() {
|
|
|
- return date;
|
|
|
|
|
|
|
+ return date == null ? "未知" : date;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public String getImageUrl() {
|
|
|
|
|
- return imageUrl == null ? iconUrl : imageUrl;
|
|
|
|
|
|
|
+ public String getTitle() {
|
|
|
|
|
+ return title == null ? "" : title;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public String getIconUrl() {
|
|
|
|
|
- return iconUrl == null ? imageUrl : iconUrl;
|
|
|
|
|
|
|
+ public String getContent() {
|
|
|
|
|
+ return content == null ? "" : content;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public String getImageUrl() {
|
|
|
|
|
+ return imageUrl;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public String getLinkUrl() {
|
|
public String getLinkUrl() {
|
|
|
return linkUrl;
|
|
return linkUrl;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public String getContent() {
|
|
|
|
|
- return content;
|
|
|
|
|
|
|
+ public String getIconUrl() {
|
|
|
|
|
+ return iconUrl;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public boolean isReaded() {
|
|
public boolean isReaded() {
|
|
|
return readed;
|
|
return readed;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public int getId() {
|
|
|
|
|
- return id;
|
|
|
|
|
|
|
+ public boolean isTag() {
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public boolean isTag() {
|
|
|
|
|
- return isTag;
|
|
|
|
|
|
|
+ @IntDef({ARTICLE_SINGLE, ARTICLE_MERGE})
|
|
|
|
|
+ @Retention(RetentionPolicy.SOURCE)
|
|
|
|
|
+ public @interface Duration {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|