|
|
|
@ -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.gtask.data;
|
|
|
|
|
|
|
|
|
|
import android.appwidget.AppWidgetManager;
|
|
|
|
@ -41,8 +25,8 @@ import java.util.ArrayList;
|
|
|
|
|
public class SqlNote {
|
|
|
|
|
private static final String TAG = SqlNote.class.getSimpleName();
|
|
|
|
|
|
|
|
|
|
private static final int INVALID_ID = -99999;
|
|
|
|
|
|
|
|
|
|
private static final int INVALID_ID = -99999;//将其初始值-99999
|
|
|
|
|
// 集合了interface NoteColumns中所有SF常量(17个)
|
|
|
|
|
public static final String[] PROJECTION_NOTE = new String[] {
|
|
|
|
|
NoteColumns.ID, NoteColumns.ALERTED_DATE, NoteColumns.BG_COLOR_ID,
|
|
|
|
|
NoteColumns.CREATED_DATE, NoteColumns.HAS_ATTACHMENT, NoteColumns.MODIFIED_DATE,
|
|
|
|
@ -51,7 +35,7 @@ public class SqlNote {
|
|
|
|
|
NoteColumns.LOCAL_MODIFIED, NoteColumns.ORIGIN_PARENT_ID, NoteColumns.GTASK_ID,
|
|
|
|
|
NoteColumns.VERSION
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//以下设置17个列的编号
|
|
|
|
|
public static final int ID_COLUMN = 0;
|
|
|
|
|
|
|
|
|
|
public static final int ALERTED_DATE_COLUMN = 1;
|
|
|
|
@ -85,7 +69,7 @@ public class SqlNote {
|
|
|
|
|
public static final int GTASK_ID_COLUMN = 15;
|
|
|
|
|
|
|
|
|
|
public static final int VERSION_COLUMN = 16;
|
|
|
|
|
|
|
|
|
|
//定义了17个内部的变量,其中12个可以由content中获得,5个需要初始化为0或者new
|
|
|
|
|
private Context mContext;
|
|
|
|
|
|
|
|
|
|
private ContentResolver mContentResolver;
|
|
|
|
@ -122,17 +106,17 @@ public class SqlNote {
|
|
|
|
|
|
|
|
|
|
private ArrayList<SqlData> mDataList;
|
|
|
|
|
|
|
|
|
|
public SqlNote(Context context) {
|
|
|
|
|
mContext = context;
|
|
|
|
|
public SqlNote(Context context) {//构造函数只有context,对所有的变量进行初始化
|
|
|
|
|
mContext = context;//变量赋值
|
|
|
|
|
mContentResolver = context.getContentResolver();
|
|
|
|
|
mIsCreate = true;
|
|
|
|
|
mIsCreate = true;//初始化
|
|
|
|
|
mId = INVALID_ID;
|
|
|
|
|
mAlertDate = 0;
|
|
|
|
|
mAlertDate = 0;//初始化
|
|
|
|
|
mBgColorId = ResourceParser.getDefaultBgId(context);
|
|
|
|
|
mCreatedDate = System.currentTimeMillis();
|
|
|
|
|
mCreatedDate = System.currentTimeMillis();//调用系统函数获得创建时间
|
|
|
|
|
mHasAttachment = 0;
|
|
|
|
|
mModifiedDate = System.currentTimeMillis();
|
|
|
|
|
mParentId = 0;
|
|
|
|
|
mModifiedDate = System.currentTimeMillis();//最后一次修改时间初始化为创建时间
|
|
|
|
|
mParentId = 0;//初始化
|
|
|
|
|
mSnippet = "";
|
|
|
|
|
mType = Notes.TYPE_NOTE;
|
|
|
|
|
mWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID;
|
|
|
|
@ -143,7 +127,7 @@ public class SqlNote {
|
|
|
|
|
mDataList = new ArrayList<SqlData>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public SqlNote(Context context, Cursor c) {
|
|
|
|
|
public SqlNote(Context context, Cursor c) {//构造函数有context和一个数据库的cursor,多数变量通过cursor指向的一条记录直接进行初始化
|
|
|
|
|
mContext = context;
|
|
|
|
|
mContentResolver = context.getContentResolver();
|
|
|
|
|
mIsCreate = false;
|
|
|
|
@ -153,8 +137,8 @@ public class SqlNote {
|
|
|
|
|
loadDataContent();
|
|
|
|
|
mDiffNoteValues = new ContentValues();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public SqlNote(Context context, long id) {
|
|
|
|
|
//SqlNote(Context context, long id)与SqlNote(Context context, long id)的实现方式基本相同
|
|
|
|
|
public SqlNote(Context context, long id) {//构造函数,对获取的id进行初始化
|
|
|
|
|
mContext = context;
|
|
|
|
|
mContentResolver = context.getContentResolver();
|
|
|
|
|
mIsCreate = false;
|
|
|
|
@ -166,7 +150,7 @@ public class SqlNote {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void loadFromCursor(long id) {
|
|
|
|
|
private void loadFromCursor(long id) {//通过id获得对应的ContentResolver中的cursor
|
|
|
|
|
Cursor c = null;
|
|
|
|
|
try {
|
|
|
|
|
c = mContentResolver.query(Notes.CONTENT_NOTE_URI, PROJECTION_NOTE, "(_id=?)",
|
|
|
|
|