mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-04-15 15:57:24 +02:00
fix #69, weird behaviour at renaming note
This commit is contained in:
parent
a05056c9f9
commit
79285a197c
@ -32,7 +32,7 @@ class RenameNoteDialog(val activity: Activity, val db: DBHelper, val note: Note,
|
|||||||
activity.toast(R.string.title_taken)
|
activity.toast(R.string.title_taken)
|
||||||
} else {
|
} else {
|
||||||
note.title = title
|
note.title = title
|
||||||
db.updateNote(note)
|
db.updateNoteTitle(note)
|
||||||
dismiss()
|
dismiss()
|
||||||
callback.invoke(note)
|
callback.invoke(note)
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ class NoteFragment : Fragment() {
|
|||||||
val oldText = note.value
|
val oldText = note.value
|
||||||
if (newText != oldText) {
|
if (newText != oldText) {
|
||||||
note.value = newText
|
note.value = newText
|
||||||
mDb.updateNote(note)
|
mDb.updateNoteValue(note)
|
||||||
context.updateWidget()
|
context.updateWidget()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,10 +125,19 @@ class DBHelper private constructor(private val mContext: Context) : SQLiteOpenHe
|
|||||||
return note
|
return note
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateNote(note: Note) {
|
fun updateNoteValue(note: Note) {
|
||||||
val values = fillContentValues(note)
|
val values = ContentValues().apply { put(COL_VALUE, note.value) }
|
||||||
|
updateNote(note.id, values)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun updateNoteTitle(note: Note) {
|
||||||
|
val values = ContentValues().apply { put(COL_TITLE, note.title) }
|
||||||
|
updateNote(note.id, values)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun updateNote(id: Int, values: ContentValues) {
|
||||||
val selection = "$COL_ID = ?"
|
val selection = "$COL_ID = ?"
|
||||||
val selectionArgs = arrayOf(note.id.toString())
|
val selectionArgs = arrayOf(id.toString())
|
||||||
mDb.update(TABLE_NAME, values, selection, selectionArgs)
|
mDb.update(TABLE_NAME, values, selection, selectionArgs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user