mirror of
https://github.com/leanote/leanote-android.git
synced 2025-10-17 07:54:24 +00:00
when in notebook mode, use current notebook as deafault for create a note, otherwise use recent notebook
This commit is contained in:
@@ -35,6 +35,7 @@ import org.houxg.leamonax.utils.ToastUtils;
|
|||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
@@ -156,9 +157,19 @@ public class MainActivity extends BaseActivity implements Navigation.Callback {
|
|||||||
Account account = AccountService.getCurrent();
|
Account account = AccountService.getCurrent();
|
||||||
Note newNote = new Note();
|
Note newNote = new Note();
|
||||||
newNote.setUserId(account.getUserId());
|
newNote.setUserId(account.getUserId());
|
||||||
Notebook recentNotebook = AppDataBase.getRecentNoteBook(AccountService.getCurrent().getUserId());
|
Notebook notebook;
|
||||||
if (recentNotebook != null) {
|
Navigation.Mode currentMode = mNavigation.getCurrentMode();
|
||||||
newNote.setNoteBookId(recentNotebook.getNotebookId());
|
if (currentMode == Navigation.Mode.NOTEBOOK) {
|
||||||
|
notebook = AppDataBase.getNotebookByLocalId(currentMode.notebookId);
|
||||||
|
} else {
|
||||||
|
notebook = AppDataBase.getRecentNoteBook(AccountService.getCurrent().getUserId());
|
||||||
|
}
|
||||||
|
if (notebook != null) {
|
||||||
|
newNote.setNoteBookId(notebook.getNotebookId());
|
||||||
|
} else {
|
||||||
|
Exception exception = new IllegalStateException(
|
||||||
|
String.format(Locale.US, "notebook is null, mode:%s, notebookLocalId:%d", currentMode, currentMode.notebookId));
|
||||||
|
CrashReport.postCatchedException(exception);
|
||||||
}
|
}
|
||||||
newNote.setIsMarkDown(account.getDefaultEditor() == Account.EDITOR_MARKDOWN);
|
newNote.setIsMarkDown(account.getDefaultEditor() == Account.EDITOR_MARKDOWN);
|
||||||
newNote.save();
|
newNote.save();
|
||||||
|
@@ -366,6 +366,10 @@ public class Navigation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Mode getCurrentMode() {
|
||||||
|
return mCurrentMode;
|
||||||
|
}
|
||||||
|
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
refreshUserInfo(AccountService.getCurrent());
|
refreshUserInfo(AccountService.getCurrent());
|
||||||
mAccountAdapter.load(AccountService.getAccountList());
|
mAccountAdapter.load(AccountService.getAccountList());
|
||||||
|
Reference in New Issue
Block a user