mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-03-19 10:00:16 +01:00
Added changing to previous note on deletion (#576)
This commit is contained in:
parent
34e2db91e7
commit
8d3bb674b9
@ -1216,17 +1216,21 @@ class MainActivity : SimpleActivity() {
|
||||
|
||||
private fun doDeleteNote(note: Note, deleteFile: Boolean) {
|
||||
ensureBackgroundThread {
|
||||
val currentNodeIndex = mNotes.indexOf(note)
|
||||
val noteToRefresh = mNotes[if (currentNodeIndex > 0) currentNodeIndex - 1 else currentNodeIndex + 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