From 270941394791053eefa8d3bff92d5d043a0e863d Mon Sep 17 00:00:00 2001 From: pzvjlefpx <1290604840@qq.com> Date: Thu, 27 Mar 2025 19:24:46 +0800 Subject: [PATCH] src --- .../net/micode/notes/gtask/data/TaskList.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/src/net/micode/notes/gtask/data/TaskList.java b/src/src/net/micode/notes/gtask/data/TaskList.java index 4ea21c5..0d27d8c 100644 --- a/src/src/net/micode/notes/gtask/data/TaskList.java +++ b/src/src/net/micode/notes/gtask/data/TaskList.java @@ -31,18 +31,23 @@ import java.util.ArrayList; public class TaskList extends Node { + // 定义一个常量,用于打印日志 private static final String TAG = TaskList.class.getSimpleName(); + // 定义一个变量,用于存储任务列表的索引 private int mIndex; + // 定义一个变量,用于存储任务列表的子任务列表 private ArrayList mChildren; + // 构造函数,初始化任务列表的子任务列表和索引 public TaskList() { super(); mChildren = new ArrayList(); mIndex = 1; } + // 获取创建任务的JSON对象 public JSONObject getCreateAction(int actionId) { JSONObject js = new JSONObject(); @@ -74,6 +79,7 @@ public class TaskList extends Node { return js; } + // 获取更新任务的JSON对象 public JSONObject getUpdateAction(int actionId) { JSONObject js = new JSONObject(); @@ -103,6 +109,7 @@ public class TaskList extends Node { return js; } + // 根据远程JSON设置任务列表的内容 public void setContentByRemoteJSON(JSONObject js) { if (js != null) { try { @@ -129,6 +136,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 +165,7 @@ public class TaskList extends Node { } } + // 获取本地JSON对象 public JSONObject getLocalJSONFromContent() { try { JSONObject js = new JSONObject(); @@ -183,6 +192,7 @@ public class TaskList extends Node { } } + // 获取同步动作 public int getSyncAction(Cursor c) { try { if (c.getInt(SqlNote.LOCAL_MODIFIED_COLUMN) == 0) { @@ -216,10 +226,12 @@ public class TaskList extends Node { return SYNC_ACTION_ERROR; } + // 获取子任务数量 public int getChildTaskCount() { return mChildren.size(); } + // 添加子任务 public boolean addChildTask(Task task) { boolean ret = false; if (task != null && !mChildren.contains(task)) { @@ -234,6 +246,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 +273,7 @@ public class TaskList extends Node { return true; } + // 移除子任务 public boolean removeChildTask(Task task) { boolean ret = false; int index = mChildren.indexOf(task); @@ -281,6 +295,7 @@ public class TaskList extends Node { return ret; } + // 移动子任务 public boolean moveChildTask(Task task, int index) { if (index < 0 || index >= mChildren.size()) { @@ -299,6 +314,7 @@ public class TaskList extends Node { return (removeChildTask(task) && addChildTask(task, index)); } + // 根据GID查找子任务 public Task findChildTaskByGid(String gid) { for (int i = 0; i < mChildren.size(); i++) { Task t = mChildren.get(i); @@ -309,10 +325,12 @@ public class TaskList extends Node { return null; } + // 获取子任务索引 public int getChildTaskIndex(Task task) { return mChildren.indexOf(task); } + // 根据索引获取子任务 public Task getChildTaskByIndex(int index) { if (index < 0 || index >= mChildren.size()) { Log.e(TAG, "getTaskByIndex: invalid index"); @@ -321,6 +339,7 @@ public class TaskList extends Node { return mChildren.get(index); } + // 根据GID获取子任务 public Task getChilTaskByGid(String gid) { for (Task task : mChildren) { if (task.getGid().equals(gid)) @@ -329,14 +348,17 @@ public class TaskList extends Node { return null; } + // 获取子任务列表 public ArrayList getChildTaskList() { return this.mChildren; } + // 设置索引 public void setIndex(int index) { this.mIndex = index; } + // 获取索引 public int getIndex() { return this.mIndex; }