correct some error by sonarlint
This commit is contained in:
parent
5179eb11ce
commit
d228b64819
|
@ -38,6 +38,7 @@ public class Note {
|
|||
private ContentValues mNoteDiffValues;
|
||||
private NoteData mNoteData;
|
||||
private static final String TAG = "Note";
|
||||
private static final String WRONGNOTEID = "Wrong note id:";
|
||||
/**
|
||||
* Create a new note id for adding a new note to databases
|
||||
*/
|
||||
|
@ -60,7 +61,7 @@ public class Note {
|
|||
noteId = 0;
|
||||
}
|
||||
if (noteId == -1) {
|
||||
throw new IllegalStateException("Wrong note id:" + noteId);
|
||||
throw new IllegalStateException(WRONGNOTEID + noteId);
|
||||
}
|
||||
return noteId;
|
||||
}
|
||||
|
@ -102,7 +103,7 @@ public class Note {
|
|||
|
||||
public boolean syncNote(Context context, long noteId) {
|
||||
if (noteId <= 0) {
|
||||
throw new IllegalArgumentException("Wrong note id:" + noteId);
|
||||
throw new IllegalArgumentException(WRONGNOTEID + noteId);
|
||||
}
|
||||
|
||||
if (!isLocalModified()) {
|
||||
|
@ -122,8 +123,7 @@ public class Note {
|
|||
}
|
||||
mNoteDiffValues.clear();
|
||||
|
||||
if (mNoteData.isLocalModified()
|
||||
&& (mNoteData.pushIntoContentResolver(context, noteId) == null)) {
|
||||
if (mNoteData.isLocalModified() && (mNoteData.pushIntoContentResolver(context, noteId) == null)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -183,10 +183,10 @@ public class Note {
|
|||
* Check for safety
|
||||
*/
|
||||
if (noteId <= 0) {
|
||||
throw new IllegalArgumentException("Wrong note id:" + noteId);
|
||||
throw new IllegalArgumentException(WRONGNOTEID + noteId);
|
||||
}
|
||||
|
||||
ArrayList<ContentProviderOperation> operationList = new ArrayList<ContentProviderOperation>();
|
||||
ArrayList<ContentProviderOperation> operationList = new ArrayList<>();
|
||||
ContentProviderOperation.Builder builder = null;
|
||||
|
||||
if(mTextDataValues.size() > 0) {
|
||||
|
@ -233,16 +233,13 @@ public class Note {
|
|||
mCallDataValues.clear();
|
||||
}
|
||||
|
||||
if (operationList.size() > 0) {
|
||||
if (!operationList.isEmpty()) {
|
||||
try {
|
||||
ContentProviderResult[] results = context.getContentResolver().applyBatch(
|
||||
Notes.AUTHORITY, operationList);
|
||||
return (results == null || results.length == 0 || results[0] == null) ? null
|
||||
: ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage()));
|
||||
return null;
|
||||
} catch (OperationApplicationException e) {
|
||||
} catch (RemoteException|OperationApplicationException e) {
|
||||
Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage()));
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue