blob: 5f314b2d76393307f9f8ea4bf61f391eec8d7921 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
package org.wordpress.android.models;
import org.json.JSONObject;
import org.wordpress.android.util.JSONUtils;
import org.wordpress.android.util.StringUtils;
public class ReaderRecommendedBlog {
public long blogId;
public long followRecoId;
public int score;
private String title;
private String blogUrl;
private String imageUrl;
private String reason;
/*
* populated by response from get/read/recommendations/mine/
*/
public static ReaderRecommendedBlog fromJson(JSONObject json) {
if (json == null) {
return null;
}
ReaderRecommendedBlog blog = new ReaderRecommendedBlog();
blog.blogId = json.optLong("blog_id");
blog.followRecoId = json.optLong("follow_reco_id");
blog.score = json.optInt("score");
blog.setTitle(JSONUtils.getString(json, "title"));
blog.setImageUrl(JSONUtils.getString(json, "image"));
blog.setReason(JSONUtils.getStringDecoded(json, "reason"));
// the "url" field points to an API endpoint, "blog_domain" contains the actual url
blog.setBlogUrl(JSONUtils.getString(json, "blog_domain"));
return blog;
}
public String getTitle() {
return StringUtils.notNullStr(title);
}
public void setTitle(String title) {
this.title = StringUtils.notNullStr(title);
}
public String getReason() {
return StringUtils.notNullStr(reason);
}
public void setReason(String reason) {
this.reason = StringUtils.notNullStr(reason);
}
public String getBlogUrl() {
return StringUtils.notNullStr(blogUrl);
}
public void setBlogUrl(String blogUrl) {
this.blogUrl = StringUtils.notNullStr(blogUrl);
}
public String getImageUrl() {
return StringUtils.notNullStr(imageUrl);
}
public void setImageUrl(String imageUrl) {
this.imageUrl = StringUtils.notNullStr(imageUrl);
}
protected boolean isSameAs(ReaderRecommendedBlog blog) {
if (blog == null) {
return false;
}
return (blog.blogId == this.blogId
&& blog.score == this.score
&& blog.followRecoId == this.followRecoId);
}
}
|