fix recent notebook might be null

This commit is contained in:
houxg
2017-02-14 11:40:20 +08:00
parent 2226ae20b9
commit 5635697223

View File

@@ -238,21 +238,19 @@ public class AppDataBase {
}
public static Notebook getRecentNoteBook(String userId) {
List<Note> recentNotes = SQLite.select()
Note recentNotes = SQLite.select()
.from(Note.class)
.where(Note_Table.userId.eq(userId))
.and(Note_Table.notebookId.notEq(""))
.orderBy(Note_Table.updatedTime, false)
.queryList();
if (CollectionUtils.isNotEmpty(recentNotes)) {
for (Note note : recentNotes) {
Notebook notebook = getNotebookByServerId(note.getNoteBookId());
if (!notebook.isDeleted()) {
return notebook;
}
.querySingle();
if (recentNotes != null) {
Notebook notebook = getNotebookByServerId(recentNotes.getNoteBookId());
if (notebook != null && !notebook.isDeleted()) {
return notebook;
}
}
return SQLite.select()
.from(Notebook.class)
.where(Notebook_Table.userId.eq(userId))