ziji wu comment

This commit is contained in:
ziji Wu 2019-09-12 16:29:32 +08:00
parent 1ee34d1899
commit c033d53e55
3 changed files with 116 additions and 43 deletions

View File

@ -6,10 +6,7 @@
</shared>
</component>
<component name="ChangeListManager">
<list default="true" id="c8515555-ebbc-49d5-889b-0c59bd6c3b6d" name="默认更改列表" comment="ziji wu comment">
<change beforePath="$PROJECT_DIR$/.gradle/5.4.1/executionHistory/executionHistory.lock" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/5.4.1/executionHistory/executionHistory.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.gradle/5.4.1/fileHashes/fileHashes.lock" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/5.4.1/fileHashes/fileHashes.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.gradle/buildOutputCleanup/buildOutputCleanup.lock" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/buildOutputCleanup/buildOutputCleanup.lock" afterDir="false" />
<list default="true" id="c8515555-ebbc-49d5-889b-0c59bd6c3b6d" name="默认更改列表" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/net/micode/notes/data/Notes.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/net/micode/notes/data/Notes.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java" beforeDir="false" afterPath="$PROJECT_DIR$/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java" afterDir="false" />
@ -36,7 +33,7 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/src/main/java/net/micode/notes/data/Contact.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="620">
<state relative-caret-position="440">
<caret line="52" column="17" selection-start-line="52" selection-start-column="17" selection-end-line="52" selection-end-column="17" />
<folding>
<element signature="imports" expanded="true" />
@ -45,11 +42,11 @@
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="true">
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/src/main/java/net/micode/notes/data/Notes.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="216">
<caret line="68" column="39" selection-start-line="68" selection-start-column="39" selection-end-line="68" selection-end-column="39" />
<state relative-caret-position="164">
<caret line="177" column="40" selection-start-line="177" selection-start-column="40" selection-end-line="177" selection-end-column="40" />
</state>
</provider>
</entry>
@ -75,11 +72,15 @@
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="355">
<caret line="49" column="36" lean-forward="true" selection-start-line="49" selection-start-column="36" selection-end-line="49" selection-end-column="36" />
<state relative-caret-position="244">
<caret line="316" column="8" lean-forward="true" selection-start-line="316" selection-start-column="8" selection-end-line="316" selection-end-column="8" />
<folding>
<element signature="e#9077#9078#0" expanded="true" />
<element signature="e#9134#9135#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
@ -129,14 +130,14 @@
<option value="$PROJECT_DIR$/app/src/main/java/net/micode/notes/tool/BackupUtils.java" />
<option value="$PROJECT_DIR$/app/src/main/res/xml/widget_4x_info.xml" />
<option value="$PROJECT_DIR$/app/src/main/java/net/micode/notes/data/Contact.java" />
<option value="$PROJECT_DIR$/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java" />
<option value="$PROJECT_DIR$/app/src/main/java/net/micode/notes/data/Notes.java" />
<option value="$PROJECT_DIR$/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java" />
</list>
</option>
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="-9" />
<option name="y" value="-9" />
<option name="x" value="85" />
<option name="y" value="25" />
<option name="width" value="1750" />
<option name="height" value="1030" />
</component>
@ -174,6 +175,37 @@
<item name="notes" type="cbb59c9e:AndroidPsiDirectoryNode" />
<item name="data" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="src" type="1abcf292:AndroidViewProjectNode" />
<item name="app" type="feadf853:AndroidModuleNode" />
<item name="java" type="edd41e36:AndroidSourceTypeNode" />
<item name="notes" type="cbb59c9e:AndroidPsiDirectoryNode" />
<item name="gtask" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="src" type="1abcf292:AndroidViewProjectNode" />
<item name="app" type="feadf853:AndroidModuleNode" />
<item name="java" type="edd41e36:AndroidSourceTypeNode" />
<item name="notes" type="cbb59c9e:AndroidPsiDirectoryNode" />
<item name="gtask" type="462c0819:PsiDirectoryNode" />
<item name="data" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="src" type="1abcf292:AndroidViewProjectNode" />
<item name="app" type="feadf853:AndroidModuleNode" />
<item name="java" type="edd41e36:AndroidSourceTypeNode" />
<item name="notes" type="cbb59c9e:AndroidPsiDirectoryNode" />
<item name="gtask" type="462c0819:PsiDirectoryNode" />
<item name="exception" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="src" type="1abcf292:AndroidViewProjectNode" />
<item name="app" type="feadf853:AndroidModuleNode" />
<item name="java" type="edd41e36:AndroidSourceTypeNode" />
<item name="notes" type="cbb59c9e:AndroidPsiDirectoryNode" />
<item name="gtask" type="462c0819:PsiDirectoryNode" />
<item name="remote" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="src" type="1abcf292:AndroidViewProjectNode" />
<item name="app" type="feadf853:AndroidModuleNode" />
@ -206,6 +238,12 @@
<item name="res" type="d4f16f75:AndroidResFolderNode" />
<item name="color" type="ddeffd01:AndroidResFolderTypeNode" />
</path>
<path>
<item name="src" type="1abcf292:AndroidViewProjectNode" />
<item name="app" type="feadf853:AndroidModuleNode" />
<item name="res" type="d4f16f75:AndroidResFolderNode" />
<item name="layout" type="ddeffd01:AndroidResFolderTypeNode" />
</path>
<path>
<item name="src" type="1abcf292:AndroidViewProjectNode" />
<item name="app" type="feadf853:AndroidModuleNode" />
@ -386,7 +424,14 @@
<option name="project" value="LOCAL" />
<updated>1568251630189</updated>
</task>
<option name="localTasksCounter" value="8" />
<task id="LOCAL-00008" summary="ziji wu comment">
<created>1568271876476</created>
<option name="number" value="00008" />
<option name="presentableId" value="LOCAL-00008" />
<option name="project" value="LOCAL" />
<updated>1568271876476</updated>
</task>
<option name="localTasksCounter" value="9" />
<servers />
</component>
<component name="TodoView">
@ -565,16 +610,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/src/main/java/net/micode/notes/data/Contact.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="620">
<caret line="52" column="17" selection-start-line="52" selection-start-column="17" selection-end-line="52" selection-end-column="17" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/src/main/java/net/micode/notes/data/NotesProvider.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="300">
@ -582,13 +617,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="355">
<caret line="49" column="36" lean-forward="true" selection-start-line="49" selection-start-column="36" selection-end-line="49" selection-end-column="36" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/src/main/java/net/micode/notes/model/Note.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-1908">
@ -608,10 +636,35 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/src/main/java/net/micode/notes/data/Contact.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="440">
<caret line="52" column="17" selection-start-line="52" selection-start-column="17" selection-end-line="52" selection-end-column="17" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/src/main/java/net/micode/notes/data/Notes.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="216">
<caret line="68" column="39" selection-start-line="68" selection-start-column="39" selection-end-line="68" selection-end-column="39" />
<state relative-caret-position="164">
<caret line="177" column="40" selection-start-line="177" selection-start-column="40" selection-end-line="177" selection-end-column="40" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/src/main/AndroidManifest.xml">
<provider selected="true" editor-type-id="text-editor" />
<provider editor-type-id="android-manifest" />
</entry>
<entry file="file://$PROJECT_DIR$/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="244">
<caret line="316" column="8" lean-forward="true" selection-start-line="316" selection-start-column="8" selection-end-line="316" selection-end-column="8" />
<folding>
<element signature="e#9077#9078#0" expanded="true" />
<element signature="e#9134#9135#0" expanded="true" />
</folding>
</state>
</provider>
</entry>

View File

@ -66,7 +66,7 @@ public class Notes {
/**
*该类声明了一系列关于便签的final变量用于数据库中标识便签没有定义方法
*该类声明了一系列关于便签的final变量用于数据库中标识便签没有定义方法
*/
public interface NoteColumns {
/**
@ -175,7 +175,7 @@ public class Notes {
}
/*
* 该类声明了一系列关于数据的final变量没有定义方法
* 该类声明了一系列关于数据的final变量用于在数据库中标识数据项没有定义方法
* */
public interface DataColumns {
/**

View File

@ -63,7 +63,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
NoteColumns.GTASK_ID + " TEXT NOT NULL DEFAULT ''," +
NoteColumns.VERSION + " INTEGER NOT NULL DEFAULT 0" +
")";
//创建SQL数据表表项String类型
private static final String CREATE_DATA_TABLE_SQL =
"CREATE TABLE " + TABLE.DATA + "(" +
DataColumns.ID + " INTEGER PRIMARY KEY," +
@ -78,7 +78,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
DataColumns.DATA4 + " TEXT NOT NULL DEFAULT ''," +
DataColumns.DATA5 + " TEXT NOT NULL DEFAULT ''" +
")";
//创建SQL数据库索引
private static final String CREATE_DATA_NOTE_ID_INDEX_SQL =
"CREATE INDEX IF NOT EXISTS note_id_index ON " +
TABLE.DATA + "(" + DataColumns.NOTE_ID + ");";
@ -96,7 +96,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
" END";
/**
* Decrease folder's note count when move note from folder
* 当从文件夹中移除便签时减少便签数量
*/
private static final String NOTE_DECREASE_FOLDER_COUNT_ON_UPDATE_TRIGGER =
"CREATE TRIGGER decrease_folder_count_on_update " +
@ -109,7 +109,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
" END";
/**
* Increase folder's note count when insert new note to the folder
* 当在文件夹中插入便签时增加便签数量
*/
private static final String NOTE_INCREASE_FOLDER_COUNT_ON_INSERT_TRIGGER =
"CREATE TRIGGER increase_folder_count_on_insert " +
@ -195,7 +195,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
" END";
/**
* Move notes belong to folder which has been moved to trash folder
* 把文件夹中已经扔到垃圾文件夹的便签删除
*/
private static final String FOLDER_MOVE_NOTES_ON_TRASH_TRIGGER =
"CREATE TRIGGER folder_move_notes_on_trash " +
@ -211,13 +211,21 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
super(context, DB_NAME, null, DB_VERSION);
}
/*
* 在数据库中添加note表项的方法
* @db SQL数据库
* */
public void createNoteTable(SQLiteDatabase db) {
db.execSQL(CREATE_NOTE_TABLE_SQL);
db.execSQL(CREATE_NOTE_TABLE_SQL);//向数据库中添加便签项
reCreateNoteTableTriggers(db);
createSystemFolder(db);
Log.d(TAG, "note table has been created");
}
/*
* 便签一被更改或者移动就更新数据库的触发器
* @db SQL数据库
* */
private void reCreateNoteTableTriggers(SQLiteDatabase db) {
db.execSQL("DROP TRIGGER IF EXISTS increase_folder_count_on_update");
db.execSQL("DROP TRIGGER IF EXISTS decrease_folder_count_on_update");
@ -263,7 +271,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
db.insert(TABLE.NOTE, null, values);
/**
* create trash folder
* 创建垃圾文件夹
*/
values.clear();
values.put(NoteColumns.ID, Notes.ID_TRASH_FOLER);
@ -271,6 +279,10 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
db.insert(TABLE.NOTE, null, values);
}
/*
* 在数据库中创建数据表的方法
* @db SQL数据库
* */
public void createDataTable(SQLiteDatabase db) {
db.execSQL(CREATE_DATA_TABLE_SQL);
reCreateDataTableTriggers(db);
@ -278,6 +290,10 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
Log.d(TAG, "data table has been created");
}
/*
* data一被更改或者删除就更新数据库的触发器
* @db SQL数据库
* */
private void reCreateDataTableTriggers(SQLiteDatabase db) {
db.execSQL("DROP TRIGGER IF EXISTS update_note_content_on_insert");
db.execSQL("DROP TRIGGER IF EXISTS update_note_content_on_update");
@ -295,6 +311,10 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
return mInstance;
}
/*
* 重写SQLLiteHelper方法在数据库中创建便签与数据表项
* @db 数据库
* */
@Override
public void onCreate(SQLiteDatabase db) {
createNoteTable(db);