From d765177e6bdcfe23f5e613a19659f88e8acbfe79 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 23 Oct 2016 18:13:46 +0200 Subject: [PATCH] make sure to save the note at creating a new one, or opening another one --- .../com/simplemobiletools/notes/activities/MainActivity.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/main/java/com/simplemobiletools/notes/activities/MainActivity.java b/app/src/main/java/com/simplemobiletools/notes/activities/MainActivity.java index 22647e0d..7a203859 100644 --- a/app/src/main/java/com/simplemobiletools/notes/activities/MainActivity.java +++ b/app/src/main/java/com/simplemobiletools/notes/activities/MainActivity.java @@ -101,6 +101,7 @@ public boolean onOptionsItemSelected(MenuItem item) { } private void updateSelectedNote(int index) { + saveText(); mConfig.setCurrentNoteIndex(index); mCurrentNote = mNotes.get(index); mNotesView.setText(mCurrentNote.getValue()); @@ -134,6 +135,7 @@ public void onClick(View v) { } else if (mDb.doesTitleExist(title)) { Utils.showToast(getApplicationContext(), R.string.title_taken); } else { + saveText(); final Note newNote = new Note(0, title, ""); final int id = mDb.insertNote(newNote); newNote.setId(id); @@ -205,6 +207,9 @@ public void onClick(DialogInterface dialog, int which) { } private void saveText() { + if (mCurrentNote == null) + return; + final String newText = getCurrentNote(); final String oldText = mCurrentNote.getValue(); if (!newText.equals(oldText)) {