-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNewsArticle.java
198 lines (163 loc) · 3.84 KB
/
NewsArticle.java
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
package com.deange.uwaterlooapi.model.news;
import android.os.Parcel;
import android.os.Parcelable;
import com.deange.uwaterlooapi.model.BaseModel;
import com.deange.uwaterlooapi.model.common.Image;
import com.deange.uwaterlooapi.utils.DateUtils;
import com.google.gson.annotations.SerializedName;
import java.util.Date;
import java.util.List;
public class NewsArticle
extends BaseModel
implements
Parcelable {
@SerializedName("id")
int mId;
@SerializedName("title")
String mTitle;
@SerializedName("description")
String mDescription;
@SerializedName("description_raw")
String mHtmlDescription;
@SerializedName("audience")
List<String> mAudience;
@SerializedName("image")
Image mImage;
@SerializedName("site_id")
String mSiteId;
@SerializedName("site_name")
String mSiteName;
@SerializedName("revision_id")
int mRevision;
@SerializedName("published")
String mPublished;
@SerializedName("updated")
String mUpdated;
@SerializedName("link")
String mLink;
protected NewsArticle(final Parcel in) {
super(in);
mId = in.readInt();
mTitle = in.readString();
mDescription = in.readString();
mHtmlDescription = in.readString();
mAudience = in.createStringArrayList();
mImage = in.readParcelable(Image.class.getClassLoader());
mSiteId = in.readString();
mSiteName = in.readString();
mRevision = in.readInt();
mPublished = in.readString();
mUpdated = in.readString();
mLink = in.readString();
}
@Override
public void writeToParcel(final Parcel dest, final int flags) {
super.writeToParcel(dest, flags);
dest.writeInt(mId);
dest.writeString(mTitle);
dest.writeString(mDescription);
dest.writeString(mHtmlDescription);
dest.writeStringList(mAudience);
dest.writeParcelable(mImage, flags);
dest.writeString(mSiteId);
dest.writeString(mSiteName);
dest.writeInt(mRevision);
dest.writeString(mPublished);
dest.writeString(mUpdated);
dest.writeString(mLink);
}
public static final Creator<NewsArticle> CREATOR = new Creator<NewsArticle>() {
@Override
public NewsArticle createFromParcel(final Parcel in) {
return new NewsArticle(in);
}
@Override
public NewsArticle[] newArray(final int size) {
return new NewsArticle[size];
}
};
/**
* Unique news id
*/
public int getId() {
return mId;
}
/**
* News title
*/
public String getTitle() {
return mTitle;
}
/**
* News body
*/
public String getDescription() {
return mDescription;
}
/**
* Raw news body (includes HTML markup)
*/
public String getHtmlDescription() {
return mHtmlDescription;
}
/**
* Audience targeted by news item
*/
public List<String> getAudience() {
return mAudience;
}
/**
* Image representing the news item
*/
public Image getImage() {
return mImage;
}
/**
* Site slug as from https://api.uwaterloo.ca/v2/resources/sites.json
*/
public String getSiteId() {
return mSiteId;
}
/**
* Full site name as from https://api.uwaterloo.ca/v2/resources/sites.json
*/
public String getSiteName() {
return mSiteName;
}
/**
* Unique id of revision of news item
*/
public int getRevision() {
return mRevision;
}
/**
* URL of news link
*/
public String getLink() {
return mLink;
}
/**
* ISO 8601 formatted publish date
*/
public Date getPublishedDate() {
return DateUtils.parseDate(mPublished);
}
/**
* ISO 8601 formatted publish date as a string
*/
public String getRawPublishedDate() {
return mPublished;
}
/**
* ISO 8601 formatted update date
*/
public Date getUpdatedDate() {
return DateUtils.parseDate(mUpdated);
}
/**
* ISO 8601 formatted update date as a string
*/
public String getRawUpdatedDate() {
return mUpdated;
}
}