林亭旭代码标注

ltx_branch
yfyl1005 2 years ago
parent 9053178fcc
commit 6db2a20ca8

@ -28,32 +28,32 @@ import net.micode.notes.tool.DataUtils;
public class NoteItemData { public class NoteItemData {
static final String [] PROJECTION = new String [] { static final String [] PROJECTION = new String [] {
NoteColumns.ID, NoteColumns.ID,//备注列ID
NoteColumns.ALERTED_DATE, NoteColumns.ALERTED_DATE,//提醒日期
NoteColumns.BG_COLOR_ID, NoteColumns.BG_COLOR_ID,//背景ID颜色
NoteColumns.CREATED_DATE, NoteColumns.CREATED_DATE,//创建数据
NoteColumns.HAS_ATTACHMENT, NoteColumns.HAS_ATTACHMENT, //具有附件
NoteColumns.MODIFIED_DATE, NoteColumns.MODIFIED_DATE,//修改数据
NoteColumns.NOTES_COUNT, NoteColumns.NOTES_COUNT,//备注计数
NoteColumns.PARENT_ID, NoteColumns.PARENT_ID,//家长ID
NoteColumns.SNIPPET, NoteColumns.SNIPPET,//片段
NoteColumns.TYPE, NoteColumns.TYPE,//类型
NoteColumns.WIDGET_ID, NoteColumns.WIDGET_ID,//部件ID
NoteColumns.WIDGET_TYPE, NoteColumns.WIDGET_TYPE,//部件类型
}; };
private static final int ID_COLUMN = 0; private static final int ID_COLUMN = 0;//ID列
private static final int ALERTED_DATE_COLUMN = 1; private static final int ALERTED_DATE_COLUMN = 1;//警报日期列
private static final int BG_COLOR_ID_COLUMN = 2; private static final int BG_COLOR_ID_COLUMN = 2;//背景颜色ID列
private static final int CREATED_DATE_COLUMN = 3; private static final int CREATED_DATE_COLUMN = 3;//创建日期列
private static final int HAS_ATTACHMENT_COLUMN = 4; private static final int HAS_ATTACHMENT_COLUMN = 4;//具有附件列
private static final int MODIFIED_DATE_COLUMN = 5; private static final int MODIFIED_DATE_COLUMN = 5;//修改日期列
private static final int NOTES_COUNT_COLUMN = 6; private static final int NOTES_COUNT_COLUMN = 6;//备注计数列
private static final int PARENT_ID_COLUMN = 7; private static final int PARENT_ID_COLUMN = 7;//父ID列
private static final int SNIPPET_COLUMN = 8; private static final int SNIPPET_COLUMN = 8;//代码段列
private static final int TYPE_COLUMN = 9; private static final int TYPE_COLUMN = 9;//类型栏
private static final int WIDGET_ID_COLUMN = 10; private static final int WIDGET_ID_COLUMN = 10;//小部件ID列
private static final int WIDGET_TYPE_COLUMN = 11; private static final int WIDGET_TYPE_COLUMN = 11;//小部件类型列
private long mId; private long mId;
private long mAlertDate; private long mAlertDate;
@ -76,16 +76,26 @@ public class NoteItemData {
private boolean mIsOneNoteFollowingFolder; private boolean mIsOneNoteFollowingFolder;
private boolean mIsMultiNotesFollowingFolder; private boolean mIsMultiNotesFollowingFolder;
public NoteItemData(Context context, Cursor cursor) { public NoteItemData(Context context, Cursor cursor) //利用光标cursor获取数据初始化NoteItemData
{
mId = cursor.getLong(ID_COLUMN); mId = cursor.getLong(ID_COLUMN);
//将数据类型变为long类
mAlertDate = cursor.getLong(ALERTED_DATE_COLUMN); mAlertDate = cursor.getLong(ALERTED_DATE_COLUMN);
//将数据类型变为long类
mBgColorId = cursor.getInt(BG_COLOR_ID_COLUMN); mBgColorId = cursor.getInt(BG_COLOR_ID_COLUMN);
//将数据类型变为int类
mCreatedDate = cursor.getLong(CREATED_DATE_COLUMN); mCreatedDate = cursor.getLong(CREATED_DATE_COLUMN);
//将数据类型变为long类
mHasAttachment = (cursor.getInt(HAS_ATTACHMENT_COLUMN) > 0) ? true : false; mHasAttachment = (cursor.getInt(HAS_ATTACHMENT_COLUMN) > 0) ? true : false;
//对HAS_ATTACHMENT_COLUMN进行判0>0为ture否则为false
mModifiedDate = cursor.getLong(MODIFIED_DATE_COLUMN); mModifiedDate = cursor.getLong(MODIFIED_DATE_COLUMN);
//将数据类型变为long类
mNotesCount = cursor.getInt(NOTES_COUNT_COLUMN); mNotesCount = cursor.getInt(NOTES_COUNT_COLUMN);
//将数据类型变为int类
mParentId = cursor.getLong(PARENT_ID_COLUMN); mParentId = cursor.getLong(PARENT_ID_COLUMN);
//将数据类型变为long类
mSnippet = cursor.getString(SNIPPET_COLUMN); mSnippet = cursor.getString(SNIPPET_COLUMN);
//将数据类型变为string类
mSnippet = mSnippet.replace(NoteEditActivity.TAG_CHECKED, "").replace( mSnippet = mSnippet.replace(NoteEditActivity.TAG_CHECKED, "").replace(
NoteEditActivity.TAG_UNCHECKED, ""); NoteEditActivity.TAG_UNCHECKED, "");
mType = cursor.getInt(TYPE_COLUMN); mType = cursor.getInt(TYPE_COLUMN);
@ -93,50 +103,57 @@ public class NoteItemData {
mWidgetType = cursor.getInt(WIDGET_TYPE_COLUMN); mWidgetType = cursor.getInt(WIDGET_TYPE_COLUMN);
mPhoneNumber = ""; mPhoneNumber = "";
//初始化电话号码信息
if (mParentId == Notes.ID_CALL_RECORD_FOLDER) { if (mParentId == Notes.ID_CALL_RECORD_FOLDER) {
mPhoneNumber = DataUtils.getCallNumberByNoteId(context.getContentResolver(), mId); mPhoneNumber = DataUtils.getCallNumberByNoteId(context.getContentResolver(), mId);
if (!TextUtils.isEmpty(mPhoneNumber)) { if (!TextUtils.isEmpty(mPhoneNumber))//mphonenumber里有符合字符串则用contart功能连接
{
mName = Contact.getContact(context, mPhoneNumber); mName = Contact.getContact(context, mPhoneNumber);
if (mName == null) { if (mName == null)//如果用户姓名为空,则令姓名等于电话号
{
mName = mPhoneNumber; mName = mPhoneNumber;
} }
} }
} }
if (mName == null) { if (mName == null)//若名字为空,则输入名字
{
mName = ""; mName = "";
} }
checkPostion(cursor); checkPostion(cursor);
} }
//据鼠标的位置设置标记,记录位置
private void checkPostion(Cursor cursor) { private void checkPostion(Cursor cursor) {
mIsLastItem = cursor.isLast() ? true : false; //初始化标记
mIsFirstItem = cursor.isFirst() ? true : false; mIsLastItem = cursor.isLast() ? true : false;//寻找光标最后位置
mIsOnlyOneItem = (cursor.getCount() == 1); mIsFirstItem = cursor.isFirst() ? true : false;//寻找光标的初始位置
mIsOnlyOneItem = (cursor.getCount() == 1);//记录是否遍历完所有路程
//初始化“多重子文件”“单一子文件”
mIsMultiNotesFollowingFolder = false; mIsMultiNotesFollowingFolder = false;
mIsOneNoteFollowingFolder = false; mIsOneNoteFollowingFolder = false;
if (mType == Notes.TYPE_NOTE && !mIsFirstItem) { //设置标记
int position = cursor.getPosition(); if (mType == Notes.TYPE_NOTE && !mIsFirstItem) {//若此时标记为note格式并且不为第一个元素
if (cursor.moveToPrevious()) { int position = cursor.getPosition();//用getPosition得到此时位置
if (cursor.moveToPrevious()) {//获取光标位置后,回溯至上一行,
if (cursor.getInt(TYPE_COLUMN) == Notes.TYPE_FOLDER if (cursor.getInt(TYPE_COLUMN) == Notes.TYPE_FOLDER
|| cursor.getInt(TYPE_COLUMN) == Notes.TYPE_SYSTEM) { || cursor.getInt(TYPE_COLUMN) == Notes.TYPE_SYSTEM) {//若光标满足系统格式或note格式
if (cursor.getCount() > (position + 1)) { if (cursor.getCount() > (position + 1))//如果得到的步数大于地址+1
mIsMultiNotesFollowingFolder = true; {
mIsMultiNotesFollowingFolder = true;//若是数据行数大于但前位置+1则设置成正确
} else { } else {
mIsOneNoteFollowingFolder = true; mIsOneNoteFollowingFolder = true;//否则单一文件夹标记为true
} }
} }
if (!cursor.moveToNext()) { if (!cursor.moveToNext()) {//若不能再往下走则报错
throw new IllegalStateException("cursor move to previous but can't move back"); throw new IllegalStateException("cursor move to previous but can't move back");
} }
} }
} }
} }
public boolean isOneFollowingFolder() { public boolean isOneFollowingFolder() {
return mIsOneNoteFollowingFolder; return mIsOneNoteFollowingFolder;
} }//文件夹注释行
public boolean isMultiFollowingFolder() { public boolean isMultiFollowingFolder() {
return mIsMultiNotesFollowingFolder; return mIsMultiNotesFollowingFolder;
@ -148,11 +165,11 @@ public class NoteItemData {
public String getCallName() { public String getCallName() {
return mName; return mName;
} }//得到用户名
public boolean isFirst() { public boolean isFirst() {
return mIsFirstItem; return mIsFirstItem;
} }//得到初始地址
public boolean isSingle() { public boolean isSingle() {
return mIsOnlyOneItem; return mIsOnlyOneItem;
@ -214,6 +231,7 @@ public class NoteItemData {
return (mAlertDate > 0); return (mAlertDate > 0);
} }
//若数据父id为保存至文件夹模式的id且满足电话号码单元不为空则isCallRecord为true
public boolean isCallRecord() { public boolean isCallRecord() {
return (mParentId == Notes.ID_CALL_RECORD_FOLDER && !TextUtils.isEmpty(mPhoneNumber)); return (mParentId == Notes.ID_CALL_RECORD_FOLDER && !TextUtils.isEmpty(mPhoneNumber));
} }
@ -222,3 +240,4 @@ public class NoteItemData {
return cursor.getInt(TYPE_COLUMN); return cursor.getInt(TYPE_COLUMN);
} }
} }

Loading…
Cancel
Save