TaskList.java

qijingxi
pbhqa7wr4 7 months ago
parent 2a75f562e9
commit 815c5ecc6e

@ -29,7 +29,9 @@ import org.json.JSONObject;
import java.util.ArrayList;
/**
* TaskListNode
*/
public class TaskList extends Node {
private static final String TAG = TaskList.class.getSimpleName();
@ -42,7 +44,9 @@ public class TaskList extends Node {
mChildren = new ArrayList<Task>();
mIndex = 1;
}
/**
* JSON
*/
public JSONObject getCreateAction(int actionId) {
JSONObject js = new JSONObject();
@ -73,7 +77,9 @@ public class TaskList extends Node {
return js;
}
/**
* JSON
*/
public JSONObject getUpdateAction(int actionId) {
JSONObject js = new JSONObject();
@ -102,7 +108,9 @@ public class TaskList extends Node {
return js;
}
/**
* JSON
*/
public void setContentByRemoteJSON(JSONObject js) {
if (js != null) {
try {
@ -128,7 +136,9 @@ public class TaskList extends Node {
}
}
}
/**
* JSON
*/
public void setContentByLocalJSON(JSONObject js) {
if (js == null || !js.has(GTaskStringUtils.META_HEAD_NOTE)) {
Log.w(TAG, "setContentByLocalJSON: nothing is avaiable");
@ -156,7 +166,9 @@ public class TaskList extends Node {
e.printStackTrace();
}
}
/**
* JSON
*/
public JSONObject getLocalJSONFromContent() {
try {
JSONObject js = new JSONObject();
@ -182,7 +194,9 @@ public class TaskList extends Node {
return null;
}
}
/**
*
*/
public int getSyncAction(Cursor c) {
try {
if (c.getInt(SqlNote.LOCAL_MODIFIED_COLUMN) == 0) {
@ -220,6 +234,9 @@ public class TaskList extends Node {
return mChildren.size();
}
/**
*
*/
public boolean addChildTask(Task task) {
boolean ret = false;
if (task != null && !mChildren.contains(task)) {
@ -233,7 +250,9 @@ public class TaskList extends Node {
}
return ret;
}
/**
*
*/
public boolean addChildTask(Task task, int index) {
if (index < 0 || index > mChildren.size()) {
Log.e(TAG, "add child task: invalid index");
@ -259,7 +278,9 @@ public class TaskList extends Node {
return true;
}
/**
*
*/
public boolean removeChildTask(Task task) {
boolean ret = false;
int index = mChildren.indexOf(task);
@ -280,7 +301,9 @@ public class TaskList extends Node {
}
return ret;
}
/**
*
*/
public boolean moveChildTask(Task task, int index) {
if (index < 0 || index >= mChildren.size()) {
@ -298,7 +321,9 @@ public class TaskList extends Node {
return true;
return (removeChildTask(task) && addChildTask(task, index));
}
/**
*
*/
public Task findChildTaskByGid(String gid) {
for (int i = 0; i < mChildren.size(); i++) {
Task t = mChildren.get(i);
@ -308,11 +333,15 @@ public class TaskList extends Node {
}
return null;
}
/**
* GID
*/
public int getChildTaskIndex(Task task) {
return mChildren.indexOf(task);
}
/**
* GID
*/
public Task getChildTaskByIndex(int index) {
if (index < 0 || index >= mChildren.size()) {
Log.e(TAG, "getTaskByIndex: invalid index");
@ -321,6 +350,9 @@ public class TaskList extends Node {
return mChildren.get(index);
}
/**
*
*/
public Task getChilTaskByGid(String gid) {
for (Task task : mChildren) {
if (task.getGid().equals(gid))
@ -328,15 +360,21 @@ public class TaskList extends Node {
}
return null;
}
/**
*
*/
public ArrayList<Task> getChildTaskList() {
return this.mChildren;
}
/**
* GID
*/
public void setIndex(int index) {
this.mIndex = index;
}
/**
*
*/
public int getIndex() {
return this.mIndex;
}

Loading…
Cancel
Save