泛读Note以及Contact做了适当批注

pull/1/head
夏彦博 2 years ago
parent 030c0bb01c
commit 1eafd04b5e

@ -25,24 +25,24 @@ import android.util.Log;
import java.util.HashMap;
public class Contact {
public class Contact {//定义一个Contact类类别标签为Contact包含一个用于存储用户信息的HashMap
private static HashMap<String, String> sContactCache;
private static final String TAG = "Contact";
//定义静态常量,用于查询指定联系人
private static final String CALLER_ID_SELECTION = "PHONE_NUMBERS_EQUAL(" + Phone.NUMBER
+ ",?) AND " + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'"
+ " AND " + Data.RAW_CONTACT_ID + " IN "
+ "(SELECT raw_contact_id "
+ " FROM phone_lookup"
+ " WHERE min_match = '+')";
//定义一个静态方法getContact可以通过Contact对象以及电话号码查询联系人。
public static String getContact(Context context, String phoneNumber) {
if(sContactCache == null) {
if(sContactCache == null) {//不存在这个联系人则新建一个存储信息
sContactCache = new HashMap<String, String>();
}
if(sContactCache.containsKey(phoneNumber)) {
return sContactCache.get(phoneNumber);
if(sContactCache.containsKey(phoneNumber)) {//如果已经包含电话号码作为关键字对应的用户
return sContactCache.get(phoneNumber);//直接返回用户的名字get返回名字
}
String selection = CALLER_ID_SELECTION.replace("+",

@ -17,7 +17,7 @@
package net.micode.notes.data;
import android.net.Uri;
public class Notes {
public class Notes {//定义Nodes类初始化参数都赋值成静态量
public static final String AUTHORITY = "micode_notes";
public static final String TAG = "Notes";
public static final int TYPE_NOTE = 0;
@ -54,14 +54,14 @@ public class Notes {
/**
* Uri to query all notes and folders
*/
public static final Uri CONTENT_NOTE_URI = Uri.parse("content://" + AUTHORITY + "/note");
public static final Uri CONTENT_NOTE_URI = Uri.parse("content://" + AUTHORITY + "/note");//指定笔记的路径
/**
* Uri to query data
*/
public static final Uri CONTENT_DATA_URI = Uri.parse("content://" + AUTHORITY + "/data");
public static final Uri CONTENT_DATA_URI = Uri.parse("content://" + AUTHORITY + "/data");//用于指定数据的路径,类似上面
public interface NoteColumns {
public interface NoteColumns {//定义笔记集ID、父集ID、创建日期修改日期等等列名称以及类型做初始化
/**
* The unique ID for a row
* <P> Type: INTEGER (long) </P>
@ -167,7 +167,7 @@ public class Notes {
public static final String VERSION = "version";
}
public interface DataColumns {
public interface DataColumns {//定义接口给每行数据ID类型所属笔记集ID内容数据等等做定义
/**
* The unique ID for a row
* <P> Type: INTEGER (long) </P>
@ -241,20 +241,20 @@ public class Notes {
public static final String DATA5 = "data5";
}
public static final class TextNote implements DataColumns {
public static final class TextNote implements DataColumns {//实现DataColumn接口为数据库查询操作提供数据列名称
/**
* Mode to indicate the text in check list mode or not
* <P> Type: Integer 1:check list mode 0: normal mode </P>
*/
public static final String MODE = DATA1;
public static final int MODE_CHECK_LIST = 1;
public static final int MODE_CHECK_LIST = 1;//表示当前文本是否还处于检查列清单的模式
public static final String CONTENT_TYPE = "vnd.android.cursor.dir/text_note";
public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/text_note";
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/text_note");
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/text_note");//指定路径
}
public static final class CallNote implements DataColumns {

Loading…
Cancel
Save