From 0c1a7f0297e65eb4c7fdc38498ee0fa9cd4d4f2e Mon Sep 17 00:00:00 2001 From: ziji Wu <2193177243@qq.com> Date: Sat, 2 Nov 2019 08:36:26 +0800 Subject: [PATCH] add code comment --- .../java/net/micode/notes/data/Contact.java | 3 ++- .../java/net/micode/notes/data/Notes.java | 27 ++++++++++--------- .../notes/data/NotesDatabaseHelper.java | 1 + .../net/micode/notes/data/NotesProvider.java | 2 +- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/app/src/main/java/net/micode/notes/data/Contact.java b/src/app/src/main/java/net/micode/notes/data/Contact.java index e16f6cc..228a75b 100644 --- a/src/app/src/main/java/net/micode/notes/data/Contact.java +++ b/src/app/src/main/java/net/micode/notes/data/Contact.java @@ -30,6 +30,7 @@ import java.util.HashMap; * */ public class Contact { private static HashMap sContactCache; + //用于记入日志的标识 private static final String TAG = "Contact"; //在数据库中的查询条件 @@ -49,7 +50,7 @@ public class Contact { sContactCache = new HashMap(); } - //如果包含电话号码,则返回电话号码 + //如果找到电话号码,则返回电话号码对应的字符串 if(sContactCache.containsKey(phoneNumber)) { return sContactCache.get(phoneNumber); } diff --git a/src/app/src/main/java/net/micode/notes/data/Notes.java b/src/app/src/main/java/net/micode/notes/data/Notes.java index 49569c5..f7b7548 100644 --- a/src/app/src/main/java/net/micode/notes/data/Notes.java +++ b/src/app/src/main/java/net/micode/notes/data/Notes.java @@ -17,15 +17,18 @@ package net.micode.notes.data; import android.net.Uri; +/* +* 该类实现了对便签的建模,实现便签的一系列接口,定义便签参数 +* */ public class Notes { public static final String AUTHORITY = "micode_notes"; - //日志标识 + //用于写入日志的标识,类名 public static final String TAG = "Notes"; - //便签类型标识 + //用于标识便签类型-普通便签 public static final int TYPE_NOTE = 0; - //文件夹标识 + //用于标识类型-文件夹 public static final int TYPE_FOLDER = 1; - //系统标识 + //用于标识类型-系统文件 public static final int TYPE_SYSTEM = 2; /** @@ -34,10 +37,10 @@ public class Notes { * {@link Notes#ID_TEMPARAY_FOLDER } is for notes belonging no folder * {@link Notes#ID_CALL_RECORD_FOLDER} is to store call records */ - 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_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 String INTENT_EXTRA_ALERT_DATE = "net.micode.notes.alert_date"; public static final String INTENT_EXTRA_BACKGROUND_ID = "net.micode.notes.background_color_id"; @@ -46,9 +49,9 @@ public class Notes { public static final String INTENT_EXTRA_FOLDER_ID = "net.micode.notes.folder_id"; public static final String INTENT_EXTRA_CALL_DATE = "net.micode.notes.call_date"; - public static final int TYPE_WIDGET_INVALIDE = -1; - public static final int TYPE_WIDGET_2X = 0; - public static final int TYPE_WIDGET_4X = 1; + public static final int TYPE_WIDGET_INVALIDE = -1;//用于标识widget无效 + public static final int TYPE_WIDGET_2X = 0;//用于标识使用的是2X大小的widget + public static final int TYPE_WIDGET_4X = 1;//用于标识使用的是4X大小的widget public static class DataConstants { public static final String NOTE = TextNote.CONTENT_ITEM_TYPE; @@ -64,7 +67,7 @@ public class Notes { public static final Uri CONTENT_DATA_URI = Uri.parse("content://" + AUTHORITY + "/data"); /** - *公用接口类 + *该类定义了一系列接口,与便签数据表,存于数据库 */ public interface NoteColumns { /** diff --git a/src/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java b/src/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java index d547fc3..6ea5b79 100644 --- a/src/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java +++ b/src/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java @@ -29,6 +29,7 @@ import net.micode.notes.data.Notes.NoteColumns; /** * 该类继承了SQLiteOpenHelper类,对SQLlite数据库进行操作 + * 提供了便签访问数据库 */ public class NotesDatabaseHelper extends SQLiteOpenHelper { //数据库名称 diff --git a/src/app/src/main/java/net/micode/notes/data/NotesProvider.java b/src/app/src/main/java/net/micode/notes/data/NotesProvider.java index 27d17be..94dcd11 100644 --- a/src/app/src/main/java/net/micode/notes/data/NotesProvider.java +++ b/src/app/src/main/java/net/micode/notes/data/NotesProvider.java @@ -35,7 +35,7 @@ import net.micode.notes.data.Notes.NoteColumns; import net.micode.notes.data.NotesDatabaseHelper.TABLE; /** - *定义便签提供者类 + *定义便签提供者类,实现了在数据库中的便签的增删查改 */ public class NotesProvider extends ContentProvider { private static final UriMatcher mMatcher;