properly switch to the new note after creating it

This commit is contained in:
tibbi 2016-10-24 23:21:09 +02:00
parent 54bcd443ec
commit fb1e766be9

View File

@ -153,11 +153,7 @@ public class MainActivity extends SimpleActivity implements OpenNoteDialog.OpenN
saveText();
final Note newNote = new Note(0, title, "");
final int id = mDb.insertNote(newNote);
newNote.setId(id);
mNotes = mDb.getNotes();
final int newNoteIndex = getNewNoteIndex(newNote);
updateSelectedNote(newNoteIndex);
updateSelectedNote(id);
alertDialog.dismiss();
invalidateOptionsMenu();
}
@ -165,18 +161,6 @@ public class MainActivity extends SimpleActivity implements OpenNoteDialog.OpenN
});
}
private int getNewNoteIndex(Note note) {
final int cnt = mNotes.size();
int index = 0;
for (int i = 0; i < cnt; i++) {
if (mNotes.get(i).equals(note)) {
index = i;
break;
}
}
return index;
}
private void displayDeleteNotePrompt() {
final Resources res = getResources();
final AlertDialog.Builder builder = new AlertDialog.Builder(this);