|
|
@ -166,6 +166,10 @@ public class SqlNote {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 从数据库中加载指定ID的数据
|
|
|
|
|
|
|
|
* @param id
|
|
|
|
|
|
|
|
*/
|
|
|
|
private void loadFromCursor(long id) {
|
|
|
|
private void loadFromCursor(long id) {
|
|
|
|
Cursor c = null;
|
|
|
|
Cursor c = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -185,6 +189,7 @@ public class SqlNote {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void loadFromCursor(Cursor c) {
|
|
|
|
private void loadFromCursor(Cursor c) {
|
|
|
|
mId = c.getLong(ID_COLUMN);
|
|
|
|
mId = c.getLong(ID_COLUMN);
|
|
|
|
mAlertDate = c.getLong(ALERTED_DATE_COLUMN);
|
|
|
|
mAlertDate = c.getLong(ALERTED_DATE_COLUMN);
|
|
|
@ -226,12 +231,21 @@ public class SqlNote {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 设置笔记的内容。根据传入的JSON对象js,首先从中获取note对象。然后根据note的类型进行不同的处理
|
|
|
|
|
|
|
|
* @param js
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
public boolean setContent(JSONObject js) {
|
|
|
|
public boolean setContent(JSONObject js) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
JSONObject note = js.getJSONObject(GTaskStringUtils.META_HEAD_NOTE);
|
|
|
|
JSONObject note = js.getJSONObject(GTaskStringUtils.META_HEAD_NOTE);
|
|
|
|
if (note.getInt(NoteColumns.TYPE) == Notes.TYPE_SYSTEM) {
|
|
|
|
if (note.getInt(NoteColumns.TYPE) == Notes.TYPE_SYSTEM) {
|
|
|
|
|
|
|
|
//无法设置系统文件夹,会记录一个警告日志
|
|
|
|
Log.w(TAG, "cannot set system folder");
|
|
|
|
Log.w(TAG, "cannot set system folder");
|
|
|
|
} else if (note.getInt(NoteColumns.TYPE) == Notes.TYPE_FOLDER) {
|
|
|
|
} else if (note.getInt(NoteColumns.TYPE) == Notes.TYPE_FOLDER) {
|
|
|
|
|
|
|
|
//只能更新摘要(snippet)和类型(type)。
|
|
|
|
|
|
|
|
// 如果正在创建新的文件夹或者摘要与原摘要不相同,则将摘要添加到差异值列表mDiffNoteValues中,
|
|
|
|
|
|
|
|
// 并更新当前的摘要mSnippet和类型mType。
|
|
|
|
// for folder we can only update the snnipet and type
|
|
|
|
// for folder we can only update the snnipet and type
|
|
|
|
String snippet = note.has(NoteColumns.SNIPPET) ? note
|
|
|
|
String snippet = note.has(NoteColumns.SNIPPET) ? note
|
|
|
|
.getString(NoteColumns.SNIPPET) : "";
|
|
|
|
.getString(NoteColumns.SNIPPET) : "";
|
|
|
@ -247,6 +261,11 @@ public class SqlNote {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mType = type;
|
|
|
|
mType = type;
|
|
|
|
} else if (note.getInt(NoteColumns.TYPE) == Notes.TYPE_NOTE) {
|
|
|
|
} else if (note.getInt(NoteColumns.TYPE) == Notes.TYPE_NOTE) {
|
|
|
|
|
|
|
|
//如果note的类型为笔记类型(Notes.TYPE_NOTE),
|
|
|
|
|
|
|
|
// 则需要进一步处理其中的数据数组dataArray。
|
|
|
|
|
|
|
|
// 先获取笔记的ID、提醒日期、背景色ID、创建日期、附件标识、修改日期、父文件夹ID、摘要、类型、
|
|
|
|
|
|
|
|
// 小部件ID、小部件类型和原始父文件夹ID等信息,并将它们与当前的值进行比较,
|
|
|
|
|
|
|
|
// 如果有改变则添加到差异值列表中并更新对应的字段
|
|
|
|
JSONArray dataArray = js.getJSONArray(GTaskStringUtils.META_HEAD_DATA);
|
|
|
|
JSONArray dataArray = js.getJSONArray(GTaskStringUtils.META_HEAD_DATA);
|
|
|
|
long id = note.has(NoteColumns.ID) ? note.getLong(NoteColumns.ID) : INVALID_ID;
|
|
|
|
long id = note.has(NoteColumns.ID) ? note.getLong(NoteColumns.ID) : INVALID_ID;
|
|
|
|
if (mIsCreate || mId != id) {
|
|
|
|
if (mIsCreate || mId != id) {
|
|
|
@ -331,6 +350,7 @@ public class SqlNote {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mOriginParent = originParent;
|
|
|
|
mOriginParent = originParent;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//遍历数据数组dataArray,将每个数据对象转换为SqlData对象,并设置其内容
|
|
|
|
for (int i = 0; i < dataArray.length(); i++) {
|
|
|
|
for (int i = 0; i < dataArray.length(); i++) {
|
|
|
|
JSONObject data = dataArray.getJSONObject(i);
|
|
|
|
JSONObject data = dataArray.getJSONObject(i);
|
|
|
|
SqlData sqlData = null;
|
|
|
|
SqlData sqlData = null;
|
|
|
|