邹兴云注释

pull/10/head
邹兴云 2 years ago
parent d600a5fb23
commit 5c27788389

@ -36,7 +36,7 @@ import java.util.HashSet;
public class DataUtils {
public static final String TAG = "DataUtils";
public static final String TAG = "DataUtils";//定义了一个Java常量变量名为TAG
public static boolean batchDeleteNotes(ContentResolver resolver, HashSet<Long> ids) {
if (ids == null) {
Log.d(TAG, "the ids is null");
@ -70,7 +70,13 @@ public class DataUtils {
Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage()));
}
return false;
}
}/*ContentResolverLongHashSet
idstrueids0true
ids0idsNotes.ID_ROOT_FOLDERContentProviderOperation使ContentProviderOperation.newDelete()operationList
使ContentResolver.applyBatch()truefalseRemoteExceptionOperationApplicationExceptionfalse*/
public static void moveNoteToFoler(ContentResolver resolver, long id, long srcFolderId, long desFolderId) {
ContentValues values = new ContentValues();
@ -78,7 +84,11 @@ public class DataUtils {
values.put(NoteColumns.ORIGIN_PARENT_ID, srcFolderId);
values.put(NoteColumns.LOCAL_MODIFIED, 1);
resolver.update(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, id), values, null, null);
}
}/*ContentResolverlongidlongsrcFolderIdlongdesFolderId
ContentValuesNoteColumns.PARENT_IDdesFolderIdNoteColumns.ORIGIN_PARENT_IDsrcFolderIdNoteColumns.LOCAL_MODIFIED1
ContentResolver.update()URIURIContentUris.withAppendedId()Notes.CONTENT_NOTE_URIidContentValuesnull*/
public static boolean batchMoveToFolder(ContentResolver resolver, HashSet<Long> ids,
long folderId) {
@ -109,7 +119,13 @@ public class DataUtils {
Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage()));
}
return false;
}
}/*ContentResolverLongHashSetidsLongfolderId
idstrue
idsidsContentProviderOperation使ContentProviderOperation.newUpdate()NoteColumns.PARENT_IDfolderIdNoteColumns.LOCAL_MODIFIED1operationList
使ContentResolver.applyBatch()truefalseRemoteExceptionOperationApplicationExceptionfalse*/
/**
* Get the all folder count except system folders {@link Notes#TYPE_SYSTEM}}
@ -134,7 +150,13 @@ public class DataUtils {
}
}
return count;
}
}/*ContentResolver
Cursor使ContentResolver.query()Notes.TYPE_FOLDERCOUNT(*)
CursorCursornull使getInt(0)IndexOutOfBoundsExceptionCursor
*/
public static boolean visibleInNoteDatabase(ContentResolver resolver, long noteId, int type) {
Cursor cursor = resolver.query(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId),
@ -151,7 +173,11 @@ public class DataUtils {
cursor.close();
}
return exist;
}
}/*ContentResolverlongnoteIdinttype
Cursor使ContentResolver.query()type
existtrueCursorexist*/
public static boolean existInNoteDatabase(ContentResolver resolver, long noteId) {
Cursor cursor = resolver.query(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId),
@ -165,7 +191,11 @@ public class DataUtils {
cursor.close();
}
return exist;
}
}/*ContentResolverlongnoteId
Cursor使ContentResolver.query()IDnoteId
existtrueCursorexist*/
public static boolean existInDataDatabase(ContentResolver resolver, long dataId) {
Cursor cursor = resolver.query(ContentUris.withAppendedId(Notes.CONTENT_DATA_URI, dataId),
@ -179,7 +209,11 @@ public class DataUtils {
cursor.close();
}
return exist;
}
}/*ContentResolverlongdataId
Cursor使ContentResolver.query()IDdataId
existtrueCursorexist*/
public static boolean checkVisibleFolderName(ContentResolver resolver, String name) {
Cursor cursor = resolver.query(Notes.CONTENT_NOTE_URI, null,
@ -195,7 +229,11 @@ public class DataUtils {
cursor.close();
}
return exist;
}
}/*ContentResolverStringname
Cursor使ContentResolver.query()Notes.TYPE_FOLDERNoteColumns.PARENT_ID <> Notes.ID_TRASH_FOLERNoteColumns.SNIPPET
existtrueCursorexist*/
public static HashSet<AppWidgetAttribute> getFolderNoteWidget(ContentResolver resolver, long folderId) {
Cursor c = resolver.query(Notes.CONTENT_NOTE_URI,
@ -222,7 +260,13 @@ public class DataUtils {
c.close();
}
return set;
}
}/*ContentResolverlongfolderIdID
Cursor使ContentResolver.query()IDfolderIdID
HashSetHashSet<AppWidgetAttribute>IDHashSetnull
CursorHashSetID*/
public static String getCallNumberByNoteId(ContentResolver resolver, long noteId) {
Cursor cursor = resolver.query(Notes.CONTENT_DATA_URI,
@ -241,7 +285,13 @@ public class DataUtils {
}
}
return "";
}
}/*ContentResolverlongnoteIdID
Cursor使ContentResolver.query()IDnoteIdMIMECallNote.CONTENT_ITEM_TYPE
Cursor*/
public static long getNoteIdByPhoneNumberAndCallDate(ContentResolver resolver, String phoneNumber, long callDate) {
Cursor cursor = resolver.query(Notes.CONTENT_DATA_URI,
@ -262,7 +312,13 @@ public class DataUtils {
cursor.close();
}
return 0;
}
}/*ContentResolverStringphoneNumberlongcallDateID
Cursor使ContentResolver.query()callDateMIMECallNote.CONTENT_ITEM_TYPEphoneNumberID
ID0
CursorID0*/
public static String getSnippetById(ContentResolver resolver, long noteId) {
Cursor cursor = resolver.query(Notes.CONTENT_NOTE_URI,
@ -280,7 +336,11 @@ public class DataUtils {
return snippet;
}
throw new IllegalArgumentException("Note is not found with id: " + noteId);
}
}/*ContentResolverlongnoteIdIDsnippet
Cursor使ContentResolver.query()IDnoteId
snippetCursorsnippetIllegalArgumentExceptionNote is not found with id: noteId*/
public static String getFormattedSnippet(String snippet) {
if (snippet != null) {
@ -292,4 +352,8 @@ public class DataUtils {
}
return snippet;
}
}
}/*Stringsnippetsnippet便
snippet使String.trim()snippet使String.indexOf()snippet使String.substring()snippetsnippetsnippet
snippet*/

Loading…
Cancel
Save