From 2bc52ecdd345949991191dd1037c26fd9dd36d73 Mon Sep 17 00:00:00 2001 From: zkx Date: Mon, 25 Dec 2023 20:47:53 +0800 Subject: [PATCH] learn: cursor --- src/main/java/net/micode/notes/data/Notes.java | 2 +- .../java/net/micode/notes/ui/NoteItemData.java | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/micode/notes/data/Notes.java b/src/main/java/net/micode/notes/data/Notes.java index be1358b..ea80c27 100644 --- a/src/main/java/net/micode/notes/data/Notes.java +++ b/src/main/java/net/micode/notes/data/Notes.java @@ -33,7 +33,7 @@ public class Notes { public static final int ID_ROOT_FOLDER = 0; public static final int ID_TEMPARAY_FOLDER = -1; public static final int ID_CALL_RECORD_FOLDER = -2; - public static final int ID_TRASH_FOLER = -3; + public static final int ID_TRASH_FOLER = -3; // TODO: 2023/12/25 有trash文件夹 public static final String INTENT_EXTRA_ALERT_DATE = "net.micode.notes.alert_date"; public static final String INTENT_EXTRA_BACKGROUND_ID = "net.micode.notes.background_color_id"; diff --git a/src/main/java/net/micode/notes/ui/NoteItemData.java b/src/main/java/net/micode/notes/ui/NoteItemData.java index 9ef849a..1e96e08 100644 --- a/src/main/java/net/micode/notes/ui/NoteItemData.java +++ b/src/main/java/net/micode/notes/ui/NoteItemData.java @@ -55,6 +55,9 @@ public class NoteItemData { private static final int WIDGET_ID_COLUMN = 10; private static final int WIDGET_TYPE_COLUMN = 11; + /** 以下这些数据,对照着NotesDatabaseHelper.java看 + * 都是数据行里设置好的属性 + * @zhoukexing 2023/12/25 20:22 */ private long mId; private long mAlertDate; private int mBgColorId; @@ -76,8 +79,16 @@ public class NoteItemData { private boolean mIsOneNoteFollowingFolder; private boolean mIsMultiNotesFollowingFolder; - public NoteItemData(Context context, Cursor cursor) { - mId = cursor.getLong(ID_COLUMN); + /** + * @method: NoteItemData + * @description: 描述一下方法的作用 + * @date: 2023/12/25 19:58 + * @author: zhoukexing + * @param: [context, cursor] + * @return: + */ + public NoteItemData(Context context, Cursor cursor) { // 把cursor理解为这样一个指针,指向一个表格 @zhoukexing 2023/12/25 20:12 + mId = cursor.getLong(ID_COLUMN); // 可以根据传入的列号获取到表格里对应列的值 @zhoukexing 2023/12/25 20:12 mAlertDate = cursor.getLong(ALERTED_DATE_COLUMN); mBgColorId = cursor.getInt(BG_COLOR_ID_COLUMN); mCreatedDate = cursor.getLong(CREATED_DATE_COLUMN); @@ -93,8 +104,9 @@ public class NoteItemData { mWidgetType = cursor.getInt(WIDGET_TYPE_COLUMN); mPhoneNumber = ""; - if (mParentId == Notes.ID_CALL_RECORD_FOLDER) { + if (mParentId == Notes.ID_CALL_RECORD_FOLDER) { //Q: 文件夹为什么有电话记录之说?怎么是通过一个便签的父文件夹来判断便签内有无电话号码?@zkx 2023/12/25 mPhoneNumber = DataUtils.getCallNumberByNoteId(context.getContentResolver(), mId); + // 根据电话号码锁定联系人名称,若不在联系人里,直接使用电话号码 @zhoukexing 2023/12/25 20:17 if (!TextUtils.isEmpty(mPhoneNumber)) { mName = Contact.getContact(context, mPhoneNumber); if (mName == null) {