pull/1/head
ZYP 1 year ago
parent 753adf1db9
commit 498629639c

@ -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<Task> mChildren;
private ArrayList<Task> mChildren;// 子任务列表
public TaskList() {
public TaskList() { // 默认构造函数
super();
mChildren = new ArrayList<Task>();
mIndex = 1;
}
// 创建操作的方法返回一个JSONObject对象
public JSONObject getCreateAction(int actionId) {
JSONObject js = new JSONObject();
@ -68,6 +68,7 @@ public class TaskList extends Node {
} 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;

Loading…
Cancel
Save