|
|
|
@ -1,19 +1,3 @@
|
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
|
*
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package net.micode.notes.ui;
|
|
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
@ -28,20 +12,20 @@ import net.micode.notes.tool.DataUtils;
|
|
|
|
|
|
|
|
|
|
public class NoteItemData {
|
|
|
|
|
static final String [] PROJECTION = new String [] {
|
|
|
|
|
NoteColumns.ID,
|
|
|
|
|
NoteColumns.ALERTED_DATE,
|
|
|
|
|
NoteColumns.BG_COLOR_ID,
|
|
|
|
|
NoteColumns.CREATED_DATE,
|
|
|
|
|
NoteColumns.HAS_ATTACHMENT,
|
|
|
|
|
NoteColumns.MODIFIED_DATE,
|
|
|
|
|
NoteColumns.NOTES_COUNT,
|
|
|
|
|
NoteColumns.PARENT_ID,
|
|
|
|
|
NoteColumns.SNIPPET,
|
|
|
|
|
NoteColumns.TYPE,
|
|
|
|
|
NoteColumns.WIDGET_ID,
|
|
|
|
|
NoteColumns.WIDGET_TYPE,
|
|
|
|
|
NoteColumns.ID,
|
|
|
|
|
NoteColumns.ALERTED_DATE,
|
|
|
|
|
NoteColumns.BG_COLOR_ID,
|
|
|
|
|
NoteColumns.CREATED_DATE,
|
|
|
|
|
NoteColumns.HAS_ATTACHMENT,
|
|
|
|
|
NoteColumns.MODIFIED_DATE,
|
|
|
|
|
NoteColumns.NOTES_COUNT,
|
|
|
|
|
NoteColumns.PARENT_ID,
|
|
|
|
|
NoteColumns.SNIPPET,
|
|
|
|
|
NoteColumns.TYPE,
|
|
|
|
|
NoteColumns.WIDGET_ID,
|
|
|
|
|
NoteColumns.WIDGET_TYPE,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//常量标记和数据就不一一标记了,意义翻译基本就知道
|
|
|
|
|
private static final int ID_COLUMN = 0;
|
|
|
|
|
private static final int ALERTED_DATE_COLUMN = 1;
|
|
|
|
|
private static final int BG_COLOR_ID_COLUMN = 2;
|
|
|
|
@ -75,8 +59,9 @@ public class NoteItemData {
|
|
|
|
|
private boolean mIsOnlyOneItem;
|
|
|
|
|
private boolean mIsOneNoteFollowingFolder;
|
|
|
|
|
private boolean mIsMultiNotesFollowingFolder;
|
|
|
|
|
|
|
|
|
|
public NoteItemData(Context context, Cursor cursor) {
|
|
|
|
|
//初始化NoteItemData,主要利用光标cursor获取的东西
|
|
|
|
|
public NoteItemData(Context context, Cursor cursor) {
|
|
|
|
|
//getxxx为转换格式
|
|
|
|
|
mId = cursor.getLong(ID_COLUMN);
|
|
|
|
|
mAlertDate = cursor.getLong(ALERTED_DATE_COLUMN);
|
|
|
|
|
mBgColorId = cursor.getInt(BG_COLOR_ID_COLUMN);
|
|
|
|
@ -92,10 +77,11 @@ public class NoteItemData {
|
|
|
|
|
mWidgetId = cursor.getInt(WIDGET_ID_COLUMN);
|
|
|
|
|
mWidgetType = cursor.getInt(WIDGET_TYPE_COLUMN);
|
|
|
|
|
|
|
|
|
|
//初始化电话号码的信息
|
|
|
|
|
mPhoneNumber = "";
|
|
|
|
|
if (mParentId == Notes.ID_CALL_RECORD_FOLDER) {
|
|
|
|
|
mPhoneNumber = DataUtils.getCallNumberByNoteId(context.getContentResolver(), mId);
|
|
|
|
|
if (!TextUtils.isEmpty(mPhoneNumber)) {
|
|
|
|
|
if (!TextUtils.isEmpty(mPhoneNumber)) {//mphonenumber里有符合字符串,则用contart功能连接
|
|
|
|
|
mName = Contact.getContact(context, mPhoneNumber);
|
|
|
|
|
if (mName == null) {
|
|
|
|
|
mName = mPhoneNumber;
|
|
|
|
@ -108,32 +94,35 @@ public class NoteItemData {
|
|
|
|
|
}
|
|
|
|
|
checkPostion(cursor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///根据鼠标的位置设置标记,和位置
|
|
|
|
|
private void checkPostion(Cursor cursor) {
|
|
|
|
|
//初始化几个标记,cursor具体功能笔记中已提到,不一一叙述
|
|
|
|
|
mIsLastItem = cursor.isLast() ? true : false;
|
|
|
|
|
mIsFirstItem = cursor.isFirst() ? true : false;
|
|
|
|
|
mIsOnlyOneItem = (cursor.getCount() == 1);
|
|
|
|
|
//初始化“多重子文件”“单一子文件”2个标记
|
|
|
|
|
mIsMultiNotesFollowingFolder = false;
|
|
|
|
|
mIsOneNoteFollowingFolder = false;
|
|
|
|
|
|
|
|
|
|
if (mType == Notes.TYPE_NOTE && !mIsFirstItem) {
|
|
|
|
|
//主要是设置上诉2标记
|
|
|
|
|
if (mType == Notes.TYPE_NOTE && !mIsFirstItem) {//若是note格式并且不是第一个元素
|
|
|
|
|
int position = cursor.getPosition();
|
|
|
|
|
if (cursor.moveToPrevious()) {
|
|
|
|
|
if (cursor.moveToPrevious()) {//获取光标位置后看上一行
|
|
|
|
|
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)) {
|
|
|
|
|
mIsMultiNotesFollowingFolder = true;
|
|
|
|
|
mIsMultiNotesFollowingFolder = true;//若是数据行数大于但前位置+1则设置成正确
|
|
|
|
|
} else {
|
|
|
|
|
mIsOneNoteFollowingFolder = true;
|
|
|
|
|
mIsOneNoteFollowingFolder = true;//否则单一文件夹标记为true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!cursor.moveToNext()) {
|
|
|
|
|
if (!cursor.moveToNext()) {//若不能再往下走则报错
|
|
|
|
|
throw new IllegalStateException("cursor move to previous but can't move back");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///以下都是获取标记没什么好说的,不过倒数第二个需要说明下,很具体看下面
|
|
|
|
|
public boolean isOneFollowingFolder() {
|
|
|
|
|
return mIsOneNoteFollowingFolder;
|
|
|
|
|
}
|
|
|
|
@ -214,6 +203,7 @@ public class NoteItemData {
|
|
|
|
|
return (mAlertDate > 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//若数据父id为保存至文件夹模式的id且满足电话号码单元不为空,则isCallRecord为true
|
|
|
|
|
public boolean isCallRecord() {
|
|
|
|
|
return (mParentId == Notes.ID_CALL_RECORD_FOLDER && !TextUtils.isEmpty(mPhoneNumber));
|
|
|
|
|
}
|
|
|
|
@ -221,4 +211,4 @@ public class NoteItemData {
|
|
|
|
|
public static int getNoteType(Cursor cursor) {
|
|
|
|
|
return cursor.getInt(TYPE_COLUMN);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|