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
This commit is contained in:
parent
ccf0acedb5
commit
392ce4279f
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -200,13 +200,14 @@ public class Note {
|
||||||
mCallDataId = id;
|
mCallDataId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//插入通话记录数据
|
||||||
void setCallData(String key, String value) {
|
void setCallData(String key, String value) {
|
||||||
mCallDataValues.put(key, value);
|
mCallDataValues.put(key, value);
|
||||||
mNoteDiffValues.put(NoteColumns.LOCAL_MODIFIED, 1);
|
mNoteDiffValues.put(NoteColumns.LOCAL_MODIFIED, 1);
|
||||||
mNoteDiffValues.put(NoteColumns.MODIFIED_DATE, System.currentTimeMillis());
|
mNoteDiffValues.put(NoteColumns.MODIFIED_DATE, System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//插入文本数据
|
||||||
void setTextData(String key, String value) {
|
void setTextData(String key, String value) {
|
||||||
mTextDataValues.put(key, value);
|
mTextDataValues.put(key, value);
|
||||||
mNoteDiffValues.put(NoteColumns.LOCAL_MODIFIED, 1);
|
mNoteDiffValues.put(NoteColumns.LOCAL_MODIFIED, 1);
|
||||||
|
@ -215,7 +216,7 @@ public class Note {
|
||||||
|
|
||||||
Uri pushIntoContentResolver(Context context, long noteId) {
|
Uri pushIntoContentResolver(Context context, long noteId) {
|
||||||
/**
|
/**
|
||||||
* Check for safety
|
* 防止无效的id
|
||||||
*/
|
*/
|
||||||
if (noteId <= 0) {
|
if (noteId <= 0) {
|
||||||
throw new IllegalArgumentException(WRONGNOTEID + noteId);
|
throw new IllegalArgumentException(WRONGNOTEID + noteId);
|
||||||
|
@ -224,42 +225,57 @@ public class Note {
|
||||||
ArrayList<ContentProviderOperation> operationList = new ArrayList<>();
|
ArrayList<ContentProviderOperation> operationList = new ArrayList<>();
|
||||||
ContentProviderOperation.Builder builder = null;
|
ContentProviderOperation.Builder builder = null;
|
||||||
|
|
||||||
|
//文本内容发生改变
|
||||||
if(mTextDataValues.size() > 0) {
|
if(mTextDataValues.size() > 0) {
|
||||||
mTextDataValues.put(DataColumns.NOTE_ID, noteId);
|
mTextDataValues.put(DataColumns.NOTE_ID, noteId);
|
||||||
|
//如果没有分配id号
|
||||||
if (mTextDataId == 0) {
|
if (mTextDataId == 0) {
|
||||||
mTextDataValues.put(DataColumns.MIME_TYPE, TextNote.CONTENT_ITEM_TYPE);
|
mTextDataValues.put(DataColumns.MIME_TYPE, TextNote.CONTENT_ITEM_TYPE);
|
||||||
Uri uri = context.getContentResolver().insert(Notes.CONTENT_DATA_URI,
|
Uri uri = context.getContentResolver().insert(Notes.CONTENT_DATA_URI,
|
||||||
mTextDataValues);
|
mTextDataValues);
|
||||||
try {
|
try {
|
||||||
|
//尝试分配id
|
||||||
setTextDataId(Long.valueOf(uri.getPathSegments().get(1)));
|
setTextDataId(Long.valueOf(uri.getPathSegments().get(1)));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
|
//分配失败
|
||||||
Log.e(TAG, "Insert new text data fail with noteId" + noteId);
|
Log.e(TAG, "Insert new text data fail with noteId" + noteId);
|
||||||
|
//清除内容
|
||||||
mTextDataValues.clear();
|
mTextDataValues.clear();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
//已经有id号,执行下列操作
|
||||||
builder = ContentProviderOperation.newUpdate(ContentUris.withAppendedId(
|
builder = ContentProviderOperation.newUpdate(ContentUris.withAppendedId(
|
||||||
Notes.CONTENT_DATA_URI, mTextDataId));
|
Notes.CONTENT_DATA_URI, mTextDataId));
|
||||||
builder.withValues(mTextDataValues);
|
builder.withValues(mTextDataValues);
|
||||||
|
//加入修改内容
|
||||||
operationList.add(builder.build());
|
operationList.add(builder.build());
|
||||||
}
|
}
|
||||||
|
//清除已修改
|
||||||
mTextDataValues.clear();
|
mTextDataValues.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//如果数据内容发生改变
|
||||||
if(mCallDataValues.size() > 0) {
|
if(mCallDataValues.size() > 0) {
|
||||||
mCallDataValues.put(DataColumns.NOTE_ID, noteId);
|
mCallDataValues.put(DataColumns.NOTE_ID, noteId);
|
||||||
|
|
||||||
if (mCallDataId == 0) {
|
if (mCallDataId == 0) {
|
||||||
|
//如果没有id号,执行下列操作
|
||||||
mCallDataValues.put(DataColumns.MIME_TYPE, CallNote.CONTENT_ITEM_TYPE);
|
mCallDataValues.put(DataColumns.MIME_TYPE, CallNote.CONTENT_ITEM_TYPE);
|
||||||
Uri uri = context.getContentResolver().insert(Notes.CONTENT_DATA_URI,
|
Uri uri = context.getContentResolver().insert(Notes.CONTENT_DATA_URI,
|
||||||
mCallDataValues);
|
mCallDataValues);
|
||||||
|
//尝试分配id
|
||||||
try {
|
try {
|
||||||
setCallDataId(Long.valueOf(uri.getPathSegments().get(1)));
|
setCallDataId(Long.valueOf(uri.getPathSegments().get(1)));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
|
//失败,错误信息加入日志
|
||||||
Log.e(TAG, "Insert new call data fail with noteId" + noteId);
|
Log.e(TAG, "Insert new call data fail with noteId" + noteId);
|
||||||
|
//清除已修改内容
|
||||||
mCallDataValues.clear();
|
mCallDataValues.clear();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
//有id号,执行下列操作
|
||||||
builder = ContentProviderOperation.newUpdate(ContentUris.withAppendedId(
|
builder = ContentProviderOperation.newUpdate(ContentUris.withAppendedId(
|
||||||
Notes.CONTENT_DATA_URI, mCallDataId));
|
Notes.CONTENT_DATA_URI, mCallDataId));
|
||||||
builder.withValues(mCallDataValues);
|
builder.withValues(mCallDataValues);
|
||||||
|
@ -269,9 +285,12 @@ public class Note {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!operationList.isEmpty()) {
|
if (!operationList.isEmpty()) {
|
||||||
|
//当前操作的便签不空,执行
|
||||||
try {
|
try {
|
||||||
ContentProviderResult[] results = context.getContentResolver().applyBatch(
|
ContentProviderResult[] results = context.getContentResolver().applyBatch(
|
||||||
Notes.AUTHORITY, operationList);
|
Notes.AUTHORITY, operationList);
|
||||||
|
//如果res无效,插入失败,返回null值
|
||||||
|
//否则返回uri
|
||||||
return (results == null || results.length == 0 || results[0] == null) ? null
|
return (results == null || results.length == 0 || results[0] == null) ? null
|
||||||
: ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId);
|
: ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId);
|
||||||
} catch (RemoteException|OperationApplicationException e) {
|
} catch (RemoteException|OperationApplicationException e) {
|
||||||
|
|
|
@ -77,7 +77,7 @@ import java.util.regex.Pattern;
|
||||||
public class NoteEditActivity extends Activity implements OnClickListener,
|
public class NoteEditActivity extends Activity implements OnClickListener,
|
||||||
NoteSettingChangedListener, OnTextViewChangeListener {
|
NoteSettingChangedListener, OnTextViewChangeListener {
|
||||||
private class HeadViewHolder {
|
private class HeadViewHolder {
|
||||||
//
|
|
||||||
public TextView tvModified;
|
public TextView tvModified;
|
||||||
|
|
||||||
public ImageView ivAlertIcon;
|
public ImageView ivAlertIcon;
|
||||||
|
|
Loading…
Reference in New Issue