handle note updating and inserting

This commit is contained in:
tibbi
2018-11-07 19:57:30 +01:00
parent 99ee559836
commit 95ab889045
6 changed files with 36 additions and 31 deletions

View File

@ -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)

View File

@ -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()
}
}