From 392ce4279f39b32cb8f2bf48b3209ff0865c07e0 Mon Sep 17 00:00:00 2001 From: ziji Wu <2193177243@qq.com> Date: Fri, 11 Oct 2019 15:47:40 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/ziji_wu' into develop # Conflicts: # src/.gradle/5.4.1/executionHistory/executionHistory.bin # src/.gradle/5.4.1/executionHistory/executionHistory.lock # src/.gradle/5.4.1/fileHashes/fileHashes.bin # src/.gradle/5.4.1/fileHashes/fileHashes.lock # src/.gradle/5.4.1/fileHashes/resourceHashesCache.bin # src/.gradle/5.4.1/javaCompile/javaCompile.lock # src/.gradle/buildOutputCleanup/buildOutputCleanup.lock # src/.gradle/buildOutputCleanup/outputFiles.bin # src/.idea/caches/build_file_checksums.ser # src/.idea/caches/gradle_models.ser # src/.idea/sonarlint/issuestore/1/e/1eb2363b523dbcae43d3c6e4790c64436af61b13 # src/.idea/sonarlint/issuestore/3/e/3e688be40dc69cfd1062f41d0fc27fe261a26710 # src/.idea/sonarlint/issuestore/5/7/577f30d26378ec8a2bd2e4a43f3c79b3f04c402c # src/.idea/sonarlint/issuestore/6/a/6a65e747031f27aef20597b4181148a9fbf963d5 # src/.idea/sonarlint/issuestore/a/7/a7641cfac724321d508c2a284223a711011a93f5 # src/.idea/sonarlint/issuestore/a/d/ad72331a1bed265bb9c0fe838faa74dbf69fce32 # src/.idea/sonarlint/issuestore/d/d/dd970bd8ce083850fca1d4d159647ccd110e57cb # src/.idea/workspace.xml # src/app/app.iml # src/app/build.gradle # src/app/build/intermediates/dex/debug/mergeDexDebug/out/classes.dex # src/app/build/intermediates/incremental/packageDebug/tmp/debug/dex-renamer-state.txt # src/app/build/intermediates/incremental/packageDebug/tmp/debug/zip-cache/dPcwR9oS2EmiImbvDZ1Qg_iwk3M= # src/app/build/intermediates/javac/debug/classes/net/micode/notes/data/NotesDatabaseHelper.class # src/app/build/intermediates/javac/debug/classes/net/micode/notes/data/NotesProvider.class # src/app/build/intermediates/processed_res/debug/processDebugResources/out/resources-debug.ap_ # src/app/build/intermediates/transforms/dexBuilder/debug/0/net/micode/notes/data/NotesDatabaseHelper.dex # src/app/build/intermediates/transforms/dexBuilder/debug/0/net/micode/notes/data/NotesProvider.dex # src/app/build/outputs/apk/debug/app-debug.apk # src/app/src/main/java/net/micode/notes/data/NotesProvider.java --- .../executionHistory/executionHistory.lock | Bin 17 -> 17 bytes src/.gradle/5.4.1/fileHashes/fileHashes.lock | Bin 17 -> 17 bytes .../buildOutputCleanup.lock | Bin 17 -> 17 bytes .../java/net/micode/notes/model/Note.java | 23 ++++++++++++++++-- .../net/micode/notes/ui/NoteEditActivity.java | 2 +- 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/.gradle/5.4.1/executionHistory/executionHistory.lock b/src/.gradle/5.4.1/executionHistory/executionHistory.lock index 0a249ac7809ece843fefe252596f5c20503b8296..fd2459166e19ea628553f3903a50db2967569186 100644 GIT binary patch literal 17 VcmZRMdf@e>LT%?K1~6dU0RTE&1#SQU literal 17 VcmZRMdf@e>LT%?K1~6dU0suN#1!@2Q diff --git a/src/.gradle/5.4.1/fileHashes/fileHashes.lock b/src/.gradle/5.4.1/fileHashes/fileHashes.lock index fa80030e00b1e4700de9b96533100204c3faab0d..6dbc64fedd76188b55cbdabccd23c7d0241d9c77 100644 GIT binary patch literal 17 VcmZR+pgrSz(_gE93}C=F2LM5Z1@8a= literal 17 VcmZR+pgrSz(_gE93}C=F3jjfb1?>O; diff --git a/src/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/src/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 50764ea8518431952177a682538f2ab5561f4a96..3c602af9dd401692265faac746c82a7a71cb9bc8 100644 GIT binary patch literal 17 VcmZRM`Mf=SLigq@1~6c91pqrZ1n>X= literal 17 VcmZRM`Mf=SLigq@1~6c91^_!Y1nvL; diff --git a/src/app/src/main/java/net/micode/notes/model/Note.java b/src/app/src/main/java/net/micode/notes/model/Note.java index d79a353..0aa447d 100644 --- a/src/app/src/main/java/net/micode/notes/model/Note.java +++ b/src/app/src/main/java/net/micode/notes/model/Note.java @@ -200,13 +200,14 @@ public class Note { mCallDataId = id; } - // + //插入通话记录数据 void setCallData(String key, String value) { mCallDataValues.put(key, value); mNoteDiffValues.put(NoteColumns.LOCAL_MODIFIED, 1); mNoteDiffValues.put(NoteColumns.MODIFIED_DATE, System.currentTimeMillis()); } + //插入文本数据 void setTextData(String key, String value) { mTextDataValues.put(key, value); mNoteDiffValues.put(NoteColumns.LOCAL_MODIFIED, 1); @@ -215,7 +216,7 @@ public class Note { Uri pushIntoContentResolver(Context context, long noteId) { /** - * Check for safety + * 防止无效的id */ if (noteId <= 0) { throw new IllegalArgumentException(WRONGNOTEID + noteId); @@ -224,42 +225,57 @@ public class Note { ArrayList operationList = new ArrayList<>(); ContentProviderOperation.Builder builder = null; + //文本内容发生改变 if(mTextDataValues.size() > 0) { mTextDataValues.put(DataColumns.NOTE_ID, noteId); + //如果没有分配id号 if (mTextDataId == 0) { mTextDataValues.put(DataColumns.MIME_TYPE, TextNote.CONTENT_ITEM_TYPE); Uri uri = context.getContentResolver().insert(Notes.CONTENT_DATA_URI, mTextDataValues); try { + //尝试分配id setTextDataId(Long.valueOf(uri.getPathSegments().get(1))); } catch (NumberFormatException e) { + //分配失败 Log.e(TAG, "Insert new text data fail with noteId" + noteId); + //清除内容 mTextDataValues.clear(); return null; } } else { + //已经有id号,执行下列操作 builder = ContentProviderOperation.newUpdate(ContentUris.withAppendedId( Notes.CONTENT_DATA_URI, mTextDataId)); builder.withValues(mTextDataValues); + //加入修改内容 operationList.add(builder.build()); } + //清除已修改 mTextDataValues.clear(); } + //如果数据内容发生改变 if(mCallDataValues.size() > 0) { mCallDataValues.put(DataColumns.NOTE_ID, noteId); + if (mCallDataId == 0) { + //如果没有id号,执行下列操作 mCallDataValues.put(DataColumns.MIME_TYPE, CallNote.CONTENT_ITEM_TYPE); Uri uri = context.getContentResolver().insert(Notes.CONTENT_DATA_URI, mCallDataValues); + //尝试分配id try { setCallDataId(Long.valueOf(uri.getPathSegments().get(1))); } catch (NumberFormatException e) { + //失败,错误信息加入日志 Log.e(TAG, "Insert new call data fail with noteId" + noteId); + //清除已修改内容 mCallDataValues.clear(); return null; } } else { + //有id号,执行下列操作 builder = ContentProviderOperation.newUpdate(ContentUris.withAppendedId( Notes.CONTENT_DATA_URI, mCallDataId)); builder.withValues(mCallDataValues); @@ -269,9 +285,12 @@ public class Note { } if (!operationList.isEmpty()) { + //当前操作的便签不空,执行 try { ContentProviderResult[] results = context.getContentResolver().applyBatch( Notes.AUTHORITY, operationList); + //如果res无效,插入失败,返回null值 + //否则返回uri return (results == null || results.length == 0 || results[0] == null) ? null : ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId); } catch (RemoteException|OperationApplicationException e) { diff --git a/src/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java b/src/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java index de47ddb..20f23ff 100644 --- a/src/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java +++ b/src/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java @@ -77,7 +77,7 @@ import java.util.regex.Pattern; public class NoteEditActivity extends Activity implements OnClickListener, NoteSettingChangedListener, OnTextViewChangeListener { private class HeadViewHolder { - // + public TextView tvModified; public ImageView ivAlertIcon;