迁移注释

main
XinqiQin 7 months ago
parent 70926b15dd
commit 9e742ff6a2

@ -14,6 +14,16 @@ import android.util.Log;
import java.util.HashMap;
/**
* @Package: net.micode.notes.data
* @ClassName: Contact
* @Description:
* ContactgetContact
* 使
* @Author: Xinqi Qin
* @CreateDate: 12/21/2024 18:31 PM
*/
public class Contact {
// 缓存已查询过的电话号码和对应的联系人名称,以减少数据库查询次数。
private static HashMap<String, String> sContactCache;
@ -27,12 +37,16 @@ public class Contact {
+ " FROM phone_lookup"
+ " WHERE min_match = '+')";
/*
*CALLER_ID_SELECTION,
*使PHONE_NUMBERS_EQUAL,使ID.
*/
/**
*
*
* @param context 访
* @param phoneNumber
* @return null
* getContact,
* getContact2contextphoneNumber,Context,访;
* 3sContactCache.get(phoneNumber)sContactCacheHashMap
* name; nullIndexOutOfBoundsException
*/
public static String getContact(Context context, String phoneNumber) {
// 初始化或获取联系人缓存
@ -57,7 +71,23 @@ public class Contact {
new String[]{phoneNumber},
null);
/*
*context.getContentResolver()query()
*Data.CONTENT_URIData.CONTENT_URIURI
*new String []{Phone.DISPLAY_NAME}
*selection
*new String[] {phoneNumber}
*null
*/
//如果查询结果不为空将第一个结果的显示名称存储在缓存中并返回该名称否则记录到错误日志并返回null。
if (cursor != null && cursor.moveToFirst()) {
/*
* namesContactCache
* IndexOutOfBoundsExceptiondebug
* 使try-catch-finally
*
*/
try {
// 从查询结果中获取联系人名称并加入缓存
String name = cursor.getString(0);
@ -65,7 +95,7 @@ public class Contact {
return name;
} catch (IndexOutOfBoundsException e) {
// 处理查询结果异常
Log.e(TAG, " Cursor get string error " + e.toString());
Log.e(TAG, " Cursor get string error " + e.toString());//调用Log.e()方法,把错误信息写到日志。
return null;
} finally {
// 关闭游标

@ -18,7 +18,19 @@ package net.micode.notes.data;
import android.net.Uri;
// Notes类定义了与笔记和文件夹相关的常量和数据列接口
/**
* @Package: net.micode.notes.data
* @ClassName: Notes
* @Description:
* NotesURI
*
*
* ID IDID
* URI 便
* @Author: Xinqi Qin
* @CreateDate: 12/22/2024 22:53 AM
*/
public class Notes {
public static final String AUTHORITY = "micode_notes"; // 用于标识内容提供者的授权名称
public static final String TAG = "Notes"; // 日志标签
@ -48,7 +60,7 @@ public class Notes {
public static final int TYPE_WIDGET_2X = 0; // 2x小部件类型
public static final int TYPE_WIDGET_4X = 1; // 4x小部件类型
public static class DataConstants {
public static class DataConstants { //定义了一个静态内部类DataConstants包含2个变量NOTE和CALL_NOTE前者用于表示数据类型为文本笔记类型后者用于表示数据类型为通话类型
public static final String NOTE = TextNote.CONTENT_ITEM_TYPE; // 笔记的内容项类型
public static final String CALL_NOTE = CallNote.CONTENT_ITEM_TYPE; // 通话记录的内容项类型
}
@ -63,8 +75,7 @@ public class Notes {
*/
public static final Uri CONTENT_DATA_URI = Uri.parse("content://" + AUTHORITY + "/data");
// 笔记和文件夹的公共列接口
public interface NoteColumns {
public interface NoteColumns {//定义了一个接口NoteColumns其中包含一些用于表示数据库中笔记文件夹各种属性的常量。
/**
* ID
* <P>: INTEGER (long)</P>
@ -237,8 +248,7 @@ public class Notes {
public static final String DATA5 = "data5";
}
// 文本笔记类实现了DataColumns接口
public static final class TextNote implements DataColumns {
public static final class TextNote implements DataColumns {//定义了一个接口DataColumns其中包含了一些用来表示笔记和文件及的数据列的常量
/**
*
* <P>: INTEGER 1: 0: </P>
@ -252,13 +262,12 @@ public class Notes {
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/text_note"); // 内容URI定义
}
// 通话记录笔记类实现了DataColumns接口
public static final class CallNote implements DataColumns {
public static final class CallNote implements DataColumns {//CallNote是一个静态内部类实现了接口DataColumns定义了一些常量和方法来表示通话笔记的属性和操作
/**
*
* <P>: INTEGER (long)</P>
*/
public static final String CALL_DATE = DATA1;
public static final String CALL_DATE = DATA1;//表示通话笔记的通话日期
/**
*

@ -13,6 +13,16 @@ import net.micode.notes.data.Notes.DataColumns;
import net.micode.notes.data.Notes.DataConstants;
import net.micode.notes.data.Notes.NoteColumns;
/**
* @Package: net.micode.notes.data
* @ClassName: NotesDatabaseHelper
* @Description:
* NotesDatabaseHelperNotesSQLiteOpenHelper
*5
*便
* @Author: Xinqi Qin
* @CreateDate: 12/22/2024 22:53 AM
*/
public class NotesDatabaseHelper extends SQLiteOpenHelper {
// 数据库名称
@ -54,7 +64,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
NoteColumns.ORIGIN_PARENT_ID + " INTEGER NOT NULL DEFAULT 0," +
NoteColumns.GTASK_ID + " TEXT NOT NULL DEFAULT ''," +
NoteColumns.VERSION + " INTEGER NOT NULL DEFAULT 0" +
")";
")";//这是用于创建便签表的SQL语句定义了便签表的结构包含便签各种属性和字段存储了用户创建的所有便签的信息。
// 创建DATA表的SQL语句
private static final String CREATE_DATA_TABLE_SQL =
@ -70,7 +80,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
DataColumns.DATA3 + " TEXT NOT NULL DEFAULT ''," +
DataColumns.DATA4 + " TEXT NOT NULL DEFAULT ''," +
DataColumns.DATA5 + " TEXT NOT NULL DEFAULT ''" +
")";
")";//这是用于定义数据表结构的SQL语句存储了与便签相关的数据信息包括了各种附加数据用来扩展便签功能。
// 创建DATA表的NOTE_ID索引的SQL语句
private static final String CREATE_DATA_NOTE_ID_INDEX_SQL =
@ -170,7 +180,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
" WHERE " + NoteColumns.PARENT_ID + "=old." + NoteColumns.ID + ";" +
" END";
// 当NOTE移动到回收站文件夹时将所有子NOTE也移动到回收站
//将已经被移动到回收站文件夹的文件夹中的便签也一并移动到回收站文件夹
private static final String FOLDER_MOVE_NOTES_ON_TRASH_TRIGGER =
"CREATE TRIGGER folder_move_notes_on_trash " +
" AFTER UPDATE ON " + TABLE.NOTE +

@ -2,6 +2,16 @@
* NotesNotes
*
*/
/**
* @Package: net.micode.notes.data
* @ClassName: NotesDatabaseHelper
* @Description:
* NotesNotes
* ContentProvider
* @Author: Xinqi Qin
* @CreateDate: 12/22/2024 22:53 AM
*/
package net.micode.notes.data;
import android.app.SearchManager;
@ -17,13 +27,13 @@ import android.text.TextUtils;
import android.util.Log;
import net.micode.notes.R;
import net.micode.notes.data.Notes.DataColumns;
import net.micode.notes.data.Notes.NoteColumns;
import net.micode.notes.data.NotesDatabaseHelper.TABLE;
import net.micode.notes.data.Notes.DataColumns;//定义了一些常量,表示数据库表的列名。
import net.micode.notes.data.Notes.NoteColumns;//定义了一些常量,表示笔记表的列名。
import net.micode.notes.data.NotesDatabaseHelper.TABLE;//定义了一个枚举类型,表示数据库表的名称。
public class NotesProvider extends ContentProvider {
private static final UriMatcher mMatcher;
public class NotesProvider extends ContentProvider {//android中的ContentProvider类,用于提供数据给其他应用程序访问。
private static final UriMatcher mMatcher;//UriMatcher是Android中的一个类用于匹配URI。
private NotesDatabaseHelper mHelper;
@ -40,14 +50,17 @@ public class NotesProvider extends ContentProvider {
// 初始化UriMatcher用于匹配不同的URI请求
static {
mMatcher = new UriMatcher(UriMatcher.NO_MATCH);
//创建一个UriMatcher对象mMatcher初始值为UriMatcher.NO_MATCH表示没有任何匹配规则。
mMatcher.addURI(Notes.AUTHORITY, "note", URI_NOTE);
//第一个参数是authority授权第二个参数是路径第三个参数是匹配的URI类型。
mMatcher.addURI(Notes.AUTHORITY, "note/#", URI_NOTE_ITEM);
mMatcher.addURI(Notes.AUTHORITY, "data", URI_DATA);
mMatcher.addURI(Notes.AUTHORITY, "data/#", URI_DATA_ITEM);
mMatcher.addURI(Notes.AUTHORITY, "search", URI_SEARCH);
mMatcher.addURI(Notes.AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY, URI_SEARCH_SUGGEST);
mMatcher.addURI(Notes.AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY + "/*", URI_SEARCH_SUGGEST);
}
}//根据不同的URI路径确定应该调用哪个处理程序来处理请求
//例如,当用户访问"http://example.com/note"时mMatcher会匹配到第一个规则
/**
* '\n'
@ -60,7 +73,8 @@ public class NotesProvider extends ContentProvider {
+ "'" + Intent.ACTION_VIEW + "' AS " + SearchManager.SUGGEST_COLUMN_INTENT_ACTION + ","
+ "'" + Notes.TextNote.CONTENT_TYPE + "' AS " + SearchManager.SUGGEST_COLUMN_INTENT_DATA;
// 用于搜索查询的SQL语句
//是一个SQL查询语句用于从数据库中检索与给定搜索条件匹配的笔记
//用于搜索笔记的投影字段列表。这个投影字段列表可以用于构建SQL查询语句以便在数据库中搜索和检索相关笔记。
private static String NOTES_SNIPPET_SEARCH_QUERY = "SELECT " + NOTES_SEARCH_PROJECTION
+ " FROM " + TABLE.NOTE
+ " WHERE " + NoteColumns.SNIPPET + " LIKE ?"
@ -92,10 +106,10 @@ public class NotesProvider extends ContentProvider {
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
String sortOrder) {
Cursor c = null;
SQLiteDatabase db = mHelper.getReadableDatabase();
SQLiteDatabase db = mHelper.getReadableDatabase();//获取可读数据库
String id = null;
// 根据URI匹配查询类型
switch (mMatcher.match(uri)) {
switch (mMatcher.match(uri)) {//匹配数据库中相应条目
case URI_NOTE:
c = db.query(TABLE.NOTE, projection, selection, selectionArgs, null, null,
sortOrder);
@ -118,7 +132,7 @@ public class NotesProvider extends ContentProvider {
case URI_SEARCH_SUGGEST:
// 处理搜索建议的特殊逻辑
if (sortOrder != null || projection != null) {
throw new IllegalArgumentException(
throw new IllegalArgumentException(//异常情况
"do not specify sortOrder, selection, selectionArgs, or projection" + "with this query");
}
@ -189,7 +203,10 @@ public class NotesProvider extends ContentProvider {
getContext().getContentResolver().notifyChange(
ContentUris.withAppendedId(Notes.CONTENT_DATA_URI, dataId), null);
}
//它通过调用getContentResolver().notifyChange()方法来实现这个功能。
//在这段代码中首先检查noteId和dataId是否大于0以确保它们是有效的ID。然后使用ContentUris.withAppendedId()方法来构建对应的URI
// 其中Notes.CONTENT_NOTE_URI和Notes.CONTENT_DATA_URI分别表示笔记和数据的URI。
// 最后调用getContext().getContentResolver().notifyChange()方法并传入构建好的URI以通知系统该URI所对应的资源已经发生了变化。
return ContentUris.withAppendedId(uri, insertedId);
}
@ -237,7 +254,7 @@ public class NotesProvider extends ContentProvider {
default:
throw new IllegalArgumentException("Unknown URI " + uri);
}
// 通知URI改变
// 通知URI改变,即系统相关数据已经发生变化,以便进行相应的更新或处理。
if (count > 0) {
if (deleteData) {
getContext().getContentResolver().notifyChange(Notes.CONTENT_NOTE_URI, null);

@ -1,5 +1,7 @@
/**
* MetaDataTask
* @Author: Xinqi Qin
* @CreateDate: 12/21/2024 18:31 PM
*/
package net.micode.notes.gtask.data;

@ -1,6 +1,8 @@
/*
* Node
*
* @Author: Xinqi Qin
* @CreateDate: 12/23/2024 10:31 PM
*/
package net.micode.notes.gtask.data;

@ -1,4 +1,5 @@
/*
*
* SqlData
* JSON Cursor
*/

@ -14,6 +14,14 @@
* limitations under the License.
*/
/*
*@Classname:TaskList
* TaskList
*@Author: Xinqi Qin
*@CreateDate: 12/24/2024 18:31 PM
*
*/
package net.micode.notes.gtask.data;
import android.database.Cursor;

@ -5,6 +5,8 @@
*
*
* :
* @Author: Xinqi Qin
* @CreateDate: 12/24/2024 9:31 PM
*/
package net.micode.notes.gtask.exception;

@ -3,6 +3,8 @@
*
* Exception
* NetworkFailureException
* @Author: Xinqi Qin
* @CreateDate: 12/23/2024 9:31 PM
*/
package net.micode.notes.gtask.exception;

@ -2,6 +2,8 @@
* GTaskASyncTask :
* AsyncTaskGoogle线
*
* @Author: Xinqi Qin
* @CreateDate: 12/24/2024 9:31 PM
*/
package net.micode.notes.gtask.remote;

@ -14,6 +14,17 @@
* limitations under the License.
*/
/*
*
* @Classname: Note
* @Description: Note
* Note IDIDURI
* URI
*
* @Author: Xinqi Qin
* @CreateDate: 12/24/2024 12:31 PM
* */
package net.micode.notes.model;
import android.content.ContentProviderOperation;

@ -14,6 +14,14 @@
* limitations under the License.
*/
/*
*
* @Classname: WorkingNote
* @Description: WorkingNote
* 便使便
* @Author: Xinqi Qin
* @CreateDate: 12/24/2024 12:31 PM
* */
package net.micode.notes.model;
import android.appwidget.AppWidgetManager;
@ -31,7 +39,6 @@ import net.micode.notes.data.Notes.NoteColumns;
import net.micode.notes.data.Notes.TextNote;
import net.micode.notes.tool.ResourceParser.NoteBgResources;
// WorkingNote类用于管理笔记的相关信息
public class WorkingNote {
// 笔记对象,包含笔记的详细信息
private Note mNote;

Loading…
Cancel
Save