diff --git a/src/net/micode/notes/gtask/data/TaskList.java b/src/net/micode/notes/gtask/data/TaskList.java index 4ea21c5..528981f 100644 --- a/src/net/micode/notes/gtask/data/TaskList.java +++ b/src/net/micode/notes/gtask/data/TaskList.java @@ -33,16 +33,16 @@ import java.util.ArrayList; public class TaskList extends Node { private static final String TAG = TaskList.class.getSimpleName(); - private int mIndex; + private int mIndex;// 索引 - private ArrayList mChildren; + private ArrayList mChildren;// 子任务列表 - public TaskList() { + public TaskList() { // 默认构造函数 super(); mChildren = new ArrayList(); mIndex = 1; } - + // 创建操作的方法,返回一个JSONObject对象 public JSONObject getCreateAction(int actionId) { JSONObject js = new JSONObject(); @@ -64,10 +64,11 @@ public class TaskList extends Node { entity.put(GTaskStringUtils.GTASK_JSON_ENTITY_TYPE, GTaskStringUtils.GTASK_JSON_TYPE_GROUP); js.put(GTaskStringUtils.GTASK_JSON_ENTITY_DELTA, entity); - + } catch (JSONException e) { Log.e(TAG, e.toString()); e.printStackTrace(); + // 如果生成JSONObject失败,则抛出ActionFailureException异常 throw new ActionFailureException("fail to generate tasklist-create jsonobject"); } @@ -121,9 +122,10 @@ public class TaskList extends Node { setName(js.getString(GTaskStringUtils.GTASK_JSON_NAME)); } - } catch (JSONException e) { + } catch (JSONException e) {// 当出现JSON解析异常时,捕获该异常 Log.e(TAG, e.toString()); - e.printStackTrace(); + e.printStackTrace(); // 打印异常的堆栈跟踪信息,有助于开发人员定位问题 + // 抛出一个新的ActionFailureException异常,并附带错误信息 throw new ActionFailureException("fail to get tasklist content from jsonobject"); } } @@ -152,8 +154,8 @@ public class TaskList extends Node { Log.e(TAG, "error type"); } } catch (JSONException e) { - Log.e(TAG, e.toString()); - e.printStackTrace(); + Log.e(TAG, e.toString());// 当出现JSON解析异常时,捕获该异常 + e.printStackTrace();// 打印异常的堆栈跟踪信息,有助于开发人员定位问题 } } @@ -162,21 +164,21 @@ public class TaskList extends Node { JSONObject js = new JSONObject(); JSONObject folder = new JSONObject(); - String folderName = getName(); + String folderName = getName();// 获取当前文件夹的名称,并赋值给folderName变量 if (getName().startsWith(GTaskStringUtils.MIUI_FOLDER_PREFFIX)) folderName = folderName.substring(GTaskStringUtils.MIUI_FOLDER_PREFFIX.length(), folderName.length()); folder.put(NoteColumns.SNIPPET, folderName); if (folderName.equals(GTaskStringUtils.FOLDER_DEFAULT) || folderName.equals(GTaskStringUtils.FOLDER_CALL_NOTE)) - folder.put(NoteColumns.TYPE, Notes.TYPE_SYSTEM); - else + folder.put(NoteColumns.TYPE, Notes.TYPE_SYSTEM); // 在folder对象中添加键值对 + else// 否则,在folder对象中添加键值对,键为NoteColumns.TYPE,值为Notes.TYPE_FOLDER folder.put(NoteColumns.TYPE, Notes.TYPE_FOLDER); js.put(GTaskStringUtils.META_HEAD_NOTE, folder); return js; - } catch (JSONException e) { + } catch (JSONException e) {// 如果在处理过程中出现JSONException异常,将异常信息记录到日志中,并打印异常堆栈信息 Log.e(TAG, e.toString()); e.printStackTrace(); return null;