mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-04-13 23:12:02 +02:00
Merge pull request #577 from Aga-C/dont-scroll-on-delete
Added changing to previous note on deletion (#576)
This commit is contained in:
commit
8cf0c2b7b8
@ -1216,17 +1216,21 @@ class MainActivity : SimpleActivity() {
|
||||
|
||||
private fun doDeleteNote(note: Note, deleteFile: Boolean) {
|
||||
ensureBackgroundThread {
|
||||
val currentNoteIndex = mNotes.indexOf(note)
|
||||
val noteToRefresh = mNotes[if (currentNoteIndex > 0) currentNoteIndex - 1 else currentNoteIndex + 1]
|
||||
|
||||
notesDB.deleteNote(note)
|
||||
widgetsDB.deleteNoteWidgets(note.id!!)
|
||||
refreshNotes(note, deleteFile)
|
||||
|
||||
refreshNotes(noteToRefresh, deleteFile)
|
||||
}
|
||||
}
|
||||
|
||||
private fun refreshNotes(note: Note, deleteFile: Boolean) {
|
||||
NotesHelper(this).getNotes {
|
||||
mNotes = it
|
||||
val firstNoteId = mNotes[0].id
|
||||
updateSelectedNote(firstNoteId!!)
|
||||
val noteId = note.id
|
||||
updateSelectedNote(noteId!!)
|
||||
if (config.widgetNoteId == note.id) {
|
||||
config.widgetNoteId = mCurrentNote.id!!
|
||||
updateWidgets()
|
||||
|
Loading…
x
Reference in New Issue
Block a user