diff --git a/src/net/micode/notes/gtask/data/TaskList.java b/src/net/micode/notes/gtask/data/TaskList.java index 4ea21c5..df9b4dd 100644 --- a/src/net/micode/notes/gtask/data/TaskList.java +++ b/src/net/micode/notes/gtask/data/TaskList.java @@ -33,7 +33,7 @@ import java.util.ArrayList; public class TaskList extends Node { private static final String TAG = TaskList.class.getSimpleName(); - private int mIndex; + private int mIndex;//当前TaskList的指针 private ArrayList mChildren; @@ -43,6 +43,7 @@ public class TaskList extends Node { mIndex = 1; } + //生成并返回一个半酣了一定数据的JSONObject实体 public JSONObject getCreateAction(int actionId) { JSONObject js = new JSONObject(); @@ -74,6 +75,7 @@ public class TaskList extends Node { return js; } + //更新JSONObject实体 public JSONObject getUpdateAction(int actionId) { JSONObject js = new JSONObject(); @@ -103,6 +105,7 @@ public class TaskList extends Node { return js; } + //通过远程JSON对象实现远程同步 public void setContentByRemoteJSON(JSONObject js) { if (js != null) { try { @@ -129,6 +132,7 @@ 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"); @@ -157,6 +161,7 @@ public class TaskList extends Node { } } + //将本地内容转换为JSONObject public JSONObject getLocalJSONFromContent() { try { JSONObject js = new JSONObject(); @@ -183,6 +188,7 @@ public class TaskList extends Node { } } + //提供同步任务,确定同步操作的类型。 public int getSyncAction(Cursor c) { try { if (c.getInt(SqlNote.LOCAL_MODIFIED_COLUMN) == 0) { @@ -220,6 +226,7 @@ public class TaskList extends Node { return mChildren.size(); } + //在当前任务表末尾添加新的任务 public boolean addChildTask(Task task) { boolean ret = false; if (task != null && !mChildren.contains(task)) { @@ -234,6 +241,7 @@ 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"); @@ -260,6 +268,7 @@ public class TaskList extends Node { return true; } + //删除任务表中的一个任务 public boolean removeChildTask(Task task) { boolean ret = false; int index = mChildren.indexOf(task); @@ -281,6 +290,7 @@ public class TaskList extends Node { return ret; } + //移动任务表中的一个任务 public boolean moveChildTask(Task task, int index) { if (index < 0 || index >= mChildren.size()) { @@ -299,6 +309,7 @@ public class TaskList extends Node { return (removeChildTask(task) && addChildTask(task, index)); } + //寻找一个任务 public Task findChildTaskByGid(String gid) { for (int i = 0; i < mChildren.size(); i++) { Task t = mChildren.get(i); @@ -309,10 +320,12 @@ public class TaskList extends Node { return null; } + //返指定index的任务 public int getChildTaskIndex(Task task) { return mChildren.indexOf(task); } + //返回指定index的任务 public Task getChildTaskByIndex(int index) { if (index < 0 || index >= mChildren.size()) { Log.e(TAG, "getTaskByIndex: invalid index"); @@ -320,7 +333,8 @@ public class TaskList extends Node { } return mChildren.get(index); } - + + //返回指定gid的任务 public Task getChilTaskByGid(String gid) { for (Task task : mChildren) { if (task.getGid().equals(gid))