From 4086638dc23fed57b6894dc268b5acd931dc7818 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=85=B4=E4=BA=91?= <1459475768@qq.com> Date: Fri, 14 Apr 2023 15:39:09 +0800 Subject: [PATCH] =?UTF-8?q?=E9=82=B9=E5=85=B4=E4=BA=91=E7=9A=84=E6=B3=A8?= =?UTF-8?q?=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/misc.xml | 2 +- .idea/modules.xml | 10 ++--- .idea/modules/app/minote.app.iml | 34 ---------------- .idea/modules/app/minote.app.main.iml | 40 ------------------- .idea/modules/app/minote.app.unitTest.iml | 28 ------------- .../notes/widget/NoteWidgetProvider.java | 21 +++++----- local.properties | 7 ++-- minote.iml | 12 ------ 8 files changed, 22 insertions(+), 132 deletions(-) delete mode 100644 .idea/modules/app/minote.app.iml delete mode 100644 .idea/modules/app/minote.app.main.iml delete mode 100644 .idea/modules/app/minote.app.unitTest.iml delete mode 100644 minote.iml diff --git a/.idea/misc.xml b/.idea/misc.xml index b8ed7db..74ce4b6 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml index 376b415..d4b4c10 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,11 +2,11 @@ - - - - - + + + + + \ No newline at end of file diff --git a/.idea/modules/app/minote.app.iml b/.idea/modules/app/minote.app.iml deleted file mode 100644 index 30ee2ea..0000000 --- a/.idea/modules/app/minote.app.iml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/app/minote.app.main.iml b/.idea/modules/app/minote.app.main.iml deleted file mode 100644 index 213d746..0000000 --- a/.idea/modules/app/minote.app.main.iml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/app/minote.app.unitTest.iml b/.idea/modules/app/minote.app.unitTest.iml deleted file mode 100644 index 3ffec00..0000000 --- a/.idea/modules/app/minote.app.unitTest.iml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/java/net/micode/notes/widget/NoteWidgetProvider.java b/app/src/main/java/net/micode/notes/widget/NoteWidgetProvider.java index 5c7f03a..f4070e9 100644 --- a/app/src/main/java/net/micode/notes/widget/NoteWidgetProvider.java +++ b/app/src/main/java/net/micode/notes/widget/NoteWidgetProvider.java @@ -65,16 +65,19 @@ public abstract class NoteWidgetProvider extends AppWidgetProvider { 具体地,使用 getContentResolver() 获取一个 ContentResolver 对象,调用 update() 方法对笔记数据库中的记录进行更新。更新的条件为 NoteColumns.WIDGET_ID + "=?",即 NoteColumns.WIDGET_ID 等于当前小部件 ID,更新的数据为 values 对象,其中 NoteColumns.WIDGET_ID 的值已经被设置为 AppWidgetManager.INVALID_APPWIDGET_ID。*/ - private Cursor getNoteWidgetInfo(Context context, int widgetId) {// 使用 getContentResolver() 方法获取 ContentResolver 对象,通过该对象进行对笔记数据库的查询操作 - return context.getContentResolver().query(Notes.CONTENT_NOTE_URI, // 使用 query() 方法查询笔记数据库,返回一个 Cursor 对象 - return context.getContentResolver().query(// 查询的 URI,笔记数据库中笔记的内容保存在该 URI 下 + private Cursor getNoteWidgetInfo(Context context, int widgetId) { + return context.getContentResolver().query(Notes.CONTENT_NOTE_URI, PROJECTION, - Notes.CONTENT_NOTE_URI, - PROJECTION, - NoteColumns.WIDGET_ID + "=? AND " + NoteColumns.PARENT_ID + "<>?",// 查询的列,即笔记 ID、笔记背景颜色 ID 和笔记摘录内容 - new String[] { String.valueOf(widgetId), String.valueOf(Notes.ID_TRASH_FOLER) },//查询的条件,即笔记关联的小部件 ID 以及笔记的父 ID 不为回收站的笔记 - null);// 排序方式,这里为 null 表示不排序 - } + NoteColumns.WIDGET_ID + "=? AND " + NoteColumns.PARENT_ID + "<>?", + new String[] { String.valueOf(widgetId), String.valueOf(Notes.ID_TRASH_FOLER) }, + null); + }/*该方法使用上下文对象获取ContentResolver,用于查询内容提供程序以获取有关笔记小部件的信息。查询在Notes.CONTENT_NOTE_URI上执行,这是表示内容提供程序中笔记表的URI。 + +PROJECTION是一个字符串数组,指定要从表中检索的列。NoteColumns.WIDGET_ID和NoteColumns.PARENT_ID是要检索的两列。NoteColumns.WIDGET_ID是包含与笔记相关联的小部件的ID的列,NoteColumns.PARENT_ID是包含笔记的父文件夹的ID的列。 + +查询还包括一个选择参数,根据小部件ID和垃圾箱文件夹的ID过滤结果。选择参数使用“?”占位符语法构造,并将占位符的实际值作为字符串数组传递到selectionArgs参数中。sortOrder参数的null值表示应以默认顺序返回结果。 + +该方法返回一个Cursor对象,表示查询结果。Cursor可用于遍历结果集的行,并检索每行的列的值。*/ protected void update(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { update(context, appWidgetManager, appWidgetIds, false); diff --git a/local.properties b/local.properties index 81bf4d8..290ecdf 100644 --- a/local.properties +++ b/local.properties @@ -2,6 +2,7 @@ # as it contains information specific to your local configuration. # # Location of the SDK. This is only used by Gradle. -# -#Fri Apr 07 12:55:13 CST 2023 -sdk.dir=D\:\\Androidsdk +# For customization when using a Version Control System, please read the +# header note. +#Thu Apr 13 12:26:55 GMT+08:00 2023 +sdk.dir=C\:\\Users\\zxy\\AppData\\Local\\Android\\Sdk diff --git a/minote.iml b/minote.iml deleted file mode 100644 index cc22eb3..0000000 --- a/minote.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file