mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-03-20 18:40:20 +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) {
|
private fun doDeleteNote(note: Note, deleteFile: Boolean) {
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
|
val currentNodeIndex = mNotes.indexOf(note)
|
||||||
|
val noteToRefresh = mNotes[if (currentNodeIndex > 0) currentNodeIndex - 1 else currentNodeIndex + 1]
|
||||||
|
|
||||||
notesDB.deleteNote(note)
|
notesDB.deleteNote(note)
|
||||||
widgetsDB.deleteNoteWidgets(note.id!!)
|
widgetsDB.deleteNoteWidgets(note.id!!)
|
||||||
refreshNotes(note, deleteFile)
|
|
||||||
|
refreshNotes(noteToRefresh, deleteFile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun refreshNotes(note: Note, deleteFile: Boolean) {
|
private fun refreshNotes(note: Note, deleteFile: Boolean) {
|
||||||
NotesHelper(this).getNotes {
|
NotesHelper(this).getNotes {
|
||||||
mNotes = it
|
mNotes = it
|
||||||
val firstNoteId = mNotes[0].id
|
val noteId = note.id
|
||||||
updateSelectedNote(firstNoteId!!)
|
updateSelectedNote(noteId!!)
|
||||||
if (config.widgetNoteId == note.id) {
|
if (config.widgetNoteId == note.id) {
|
||||||
config.widgetNoteId = mCurrentNote.id!!
|
config.widgetNoteId = mCurrentNote.id!!
|
||||||
updateWidgets()
|
updateWidgets()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user