diff --git a/src/Notes-master/Notes-master/src/net/micode/notes/gtask/data/TaskList.java b/src/Notes-master/Notes-master/src/net/micode/notes/gtask/data/TaskList.java index 4ea21c5..696007e 100644 --- a/src/Notes-master/Notes-master/src/net/micode/notes/gtask/data/TaskList.java +++ b/src/Notes-master/Notes-master/src/net/micode/notes/gtask/data/TaskList.java @@ -29,7 +29,9 @@ import org.json.JSONObject; import java.util.ArrayList; - +/** + * TaskList类继承自Node类,代表一个任务列表实体。 + */ 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(); 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 getChildTaskList() { return this.mChildren; } - +/** + * 根据GID获取任务列表中的任务。 + */ public void setIndex(int index) { this.mIndex = index; } - + /** + * 获取任务列表的索引。 + */ public int getIndex() { return this.mIndex; }