Skip to content

Commit 8cf0c2b

Browse files
authored
Merge pull request #577 from Aga-C/dont-scroll-on-delete
Added changing to previous note on deletion (#576)
2 parents 054f0ea + c58f0f3 commit 8cf0c2b

File tree

1 file changed

+7
-3
lines changed
  • app/src/main/kotlin/com/simplemobiletools/notes/pro/activities

1 file changed

+7
-3
lines changed

app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,17 +1216,21 @@ class MainActivity : SimpleActivity() {
12161216

12171217
private fun doDeleteNote(note: Note, deleteFile: Boolean) {
12181218
ensureBackgroundThread {
1219+
val currentNoteIndex = mNotes.indexOf(note)
1220+
val noteToRefresh = mNotes[if (currentNoteIndex > 0) currentNoteIndex - 1 else currentNoteIndex + 1]
1221+
12191222
notesDB.deleteNote(note)
12201223
widgetsDB.deleteNoteWidgets(note.id!!)
1221-
refreshNotes(note, deleteFile)
1224+
1225+
refreshNotes(noteToRefresh, deleteFile)
12221226
}
12231227
}
12241228

12251229
private fun refreshNotes(note: Note, deleteFile: Boolean) {
12261230
NotesHelper(this).getNotes {
12271231
mNotes = it
1228-
val firstNoteId = mNotes[0].id
1229-
updateSelectedNote(firstNoteId!!)
1232+
val noteId = note.id
1233+
updateSelectedNote(noteId!!)
12301234
if (config.widgetNoteId == note.id) {
12311235
config.widgetNoteId = mCurrentNote.id!!
12321236
updateWidgets()

0 commit comments

Comments
 (0)