use one shared function for updating note title, value, path

This commit is contained in:
tibbi
2018-11-07 12:58:35 +01:00
parent 2fc3d8cba9
commit f26ea25a1e
4 changed files with 12 additions and 24 deletions

View File

@ -30,7 +30,9 @@ class RenameNoteDialog(val activity: SimpleActivity, val note: Note, callback: (
else -> {
note.title = title
val path = note.path
if (path.isNotEmpty()) {
if (path.isEmpty()) {
activity.dbHelper.updateNote(note)
} else {
if (title.isEmpty()) {
activity.toast(R.string.filename_cannot_be_empty)
return@setOnClickListener
@ -46,14 +48,14 @@ class RenameNoteDialog(val activity: SimpleActivity, val note: Note, callback: (
activity.renameFile(file.absolutePath, newFile.absolutePath) {
if (it) {
note.path = newFile.absolutePath
activity.dbHelper.updateNotePath(note)
activity.dbHelper.updateNote(note)
} else {
activity.toast(R.string.rename_file_error)
return@renameFile
}
}
}
activity.dbHelper.updateNoteTitle(note)
dismiss()
callback(note)
}