-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Copy pathToDoItem.java
115 lines (90 loc) · 3.41 KB
/
ToDoItem.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
package com.example.avjindersinghsekhon.minimaltodo.Utility;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.Serializable;
import java.util.Date;
import java.util.UUID;
public class ToDoItem implements Serializable {
private String mToDoText;
private boolean mHasReminder;
//add description
private String mToDoDescription;
// private Date mLastEdited;
private int mTodoColor;
private Date mToDoDate;
private UUID mTodoIdentifier;
//add description
private static final String TODODESCRIPTION = "tododescription";
private static final String TODOTEXT = "todotext";
private static final String TODOREMINDER = "todoreminder";
// private static final String TODOLASTEDITED = "todolastedited";
private static final String TODOCOLOR = "todocolor";
private static final String TODODATE = "tododate";
private static final String TODOIDENTIFIER = "todoidentifier";
public ToDoItem(String todoBody,String tododescription, boolean hasReminder, Date toDoDate) {
mToDoText = todoBody;
mHasReminder = hasReminder;
mToDoDate = toDoDate;
mToDoDescription = tododescription;
mTodoColor = 1677725;
mTodoIdentifier = UUID.randomUUID();
}
public ToDoItem(JSONObject jsonObject) throws JSONException {
mToDoText = jsonObject.getString(TODOTEXT);
mToDoDescription = jsonObject.getString(TODODESCRIPTION);
mHasReminder = jsonObject.getBoolean(TODOREMINDER);
mTodoColor = jsonObject.getInt(TODOCOLOR);
mTodoIdentifier = UUID.fromString(jsonObject.getString(TODOIDENTIFIER));
// if(jsonObject.has(TODOLASTEDITED)){
// mLastEdited = new Date(jsonObject.getLong(TODOLASTEDITED));
// }
if (jsonObject.has(TODODATE)) {
mToDoDate = new Date(jsonObject.getLong(TODODATE));
}
}
public JSONObject toJSON() throws JSONException {
JSONObject jsonObject = new JSONObject();
jsonObject.put(TODOTEXT, mToDoText);
jsonObject.put(TODOREMINDER, mHasReminder);
jsonObject.put(TODODESCRIPTION, mToDoDescription);
// jsonObject.put(TODOLASTEDITED, mLastEdited.getTime());
if (mToDoDate != null) {
jsonObject.put(TODODATE, mToDoDate.getTime());
}
jsonObject.put(TODOCOLOR, mTodoColor);
jsonObject.put(TODOIDENTIFIER, mTodoIdentifier.toString());
return jsonObject;
}
public ToDoItem() {
this("Clean my room","Sweep and Mop my Room", true, new Date());
}
public String getmToDoDescription() { return mToDoDescription;}
public void setmToDoDescription(String mToDoDescription){this.mToDoDescription = mToDoDescription;}
public String getToDoText() {
return mToDoText;
}
public void setToDoText(String mToDoText) {
this.mToDoText = mToDoText;
}
public boolean hasReminder() {
return mHasReminder;
}
public void setHasReminder(boolean mHasReminder) {
this.mHasReminder = mHasReminder;
}
public Date getToDoDate() {
return mToDoDate;
}
public int getTodoColor() {
return mTodoColor;
}
public void setTodoColor(int mTodoColor) {
this.mTodoColor = mTodoColor;
}
public void setToDoDate(Date mToDoDate) {
this.mToDoDate = mToDoDate;
}
public UUID getIdentifier() {
return mTodoIdentifier;
}
}