fix wrong condition of local note

This commit is contained in:
houxg
2017-02-21 14:53:40 +08:00
parent 99d07c90bf
commit 75582c2167
2 changed files with 11 additions and 1 deletions

View File

@@ -1,5 +1,7 @@
package org.houxg.leamonax.model; package org.houxg.leamonax.model;
import android.text.TextUtils;
import com.elvishew.xlog.XLog; import com.elvishew.xlog.XLog;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import com.raizlabs.android.dbflow.annotation.Column; import com.raizlabs.android.dbflow.annotation.Column;
@@ -193,6 +195,14 @@ public class Note extends BaseModel implements Serializable {
return tagData; return tagData;
} }
public boolean isTotalEmpty() {
return TextUtils.isEmpty(title) && TextUtils.isEmpty(content);
}
public boolean isLocalNote() {
return TextUtils.isEmpty(noteId);
}
public void updateTags() { public void updateTags() {
if (CollectionUtils.isEmpty(tagData)) { if (CollectionUtils.isEmpty(tagData)) {
tags = ""; tags = "";

View File

@@ -204,7 +204,7 @@ public class NoteService {
Map<String, RequestBody> requestBodyMap = generateCommonBodyMap(modifiedNote); Map<String, RequestBody> requestBodyMap = generateCommonBodyMap(modifiedNote);
List<MultipartBody.Part> fileBodies = handleFileBodies(modifiedNote, requestBodyMap); List<MultipartBody.Part> fileBodies = handleFileBodies(modifiedNote, requestBodyMap);
Call<Note> call; Call<Note> call;
if (modifiedNote.getUsn() == 0) { if (modifiedNote.isLocalNote()) {
call = ApiProvider.getInstance().getNoteApi().add(requestBodyMap, fileBodies); call = ApiProvider.getInstance().getNoteApi().add(requestBodyMap, fileBodies);
} else { } else {
Note remoteNote = RetrofitUtils.excuteWithException(getNoteByServerId(modifiedNote.getNoteId())); Note remoteNote = RetrofitUtils.excuteWithException(getNoteByServerId(modifiedNote.getNoteId()));