mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-06-05 17:00:23 +02:00
handle note updating and inserting
This commit is contained in:
@ -108,13 +108,6 @@ class DBHelper private constructor(private val mContext: Context) : SQLiteOpenHe
|
||||
return 0
|
||||
}
|
||||
|
||||
fun updateNote(note: Note) {
|
||||
val values = fillNoteContentValues(note)
|
||||
val selection = "$COL_ID = ?"
|
||||
val selectionArgs = arrayOf(note.id.toString())
|
||||
mDb.update(NOTES_TABLE_NAME, values, selection, selectionArgs)
|
||||
}
|
||||
|
||||
fun getWidgets(): ArrayList<Widget> {
|
||||
val widgets = ArrayList<Widget>()
|
||||
val cols = arrayOf(COL_WIDGET_ID, COL_NOTE_ID)
|
||||
|
@ -41,4 +41,13 @@ class NotesHelper(val activity: Activity) {
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
|
||||
fun insertOrUpdateNote(note: Note, callback: ((newNoteId: Long) -> Unit)? = null) {
|
||||
Thread {
|
||||
val noteId = activity.notesDB.insertOrUpdate(note)
|
||||
activity.runOnUiThread {
|
||||
callback?.invoke(noteId)
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user