blob: ef55cdf7b476c6decd915620876a0c1f4951a91b (
plain) (
blame)
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
|
package com.camilstaps.taize;
import com.camilstaps.common.Date;
import com.camilstaps.common.DatedString;
import org.json.JSONException;
import org.json.JSONObject;
/**
* Created by camilstaps on 15-4-15.
*/
public class Podcast extends DatedString implements Comparable<Podcast> {
public Podcast(Date date, String title, String url) throws JSONException {
super(date, (new JSONObject()).put("title", title).put("url", url).toString());
}
private JSONObject getJSONObject() {
try {
return new JSONObject(getString());
} catch (JSONException e) {
return null;
}
}
public String getTitle() {
try {
return getJSONObject().getString("title");
} catch (JSONException e) {
return "";
}
}
public String getUrl() {
try {
return getJSONObject().getString("url");
} catch (JSONException e) {
return "";
}
}
@Override
public int compareTo(Podcast another) {
return getDate().compareTo(another.getDate());
}
}
|