mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-02-10 00:10:48 +01:00
properly clean up removed widgets from the database
This commit is contained in:
parent
af199908d9
commit
42c14576be
@ -48,4 +48,13 @@ class MyWidgetProvider : AppWidgetProvider() {
|
|||||||
}
|
}
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDeleted(context: Context, appWidgetIds: IntArray) {
|
||||||
|
super.onDeleted(context, appWidgetIds)
|
||||||
|
Thread {
|
||||||
|
appWidgetIds.forEach {
|
||||||
|
context.widgetsDB.deleteWidgetId(it)
|
||||||
|
}
|
||||||
|
}.start()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,4 +16,7 @@ interface WidgetsDao {
|
|||||||
|
|
||||||
@Query("DELETE FROM widgets WHERE note_id = :noteId")
|
@Query("DELETE FROM widgets WHERE note_id = :noteId")
|
||||||
fun deleteNoteWidgets(noteId: Long)
|
fun deleteNoteWidgets(noteId: Long)
|
||||||
|
|
||||||
|
@Query("DELETE FROM widgets WHERE widget_id = :widgetId")
|
||||||
|
fun deleteWidgetId(widgetId: Int)
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,6 @@ import androidx.room.PrimaryKey
|
|||||||
|
|
||||||
@Entity(tableName = "widgets", indices = [(Index(value = ["widget_id"], unique = true))])
|
@Entity(tableName = "widgets", indices = [(Index(value = ["widget_id"], unique = true))])
|
||||||
data class Widget(
|
data class Widget(
|
||||||
@PrimaryKey(autoGenerate = true) var id: Int?,
|
@PrimaryKey(autoGenerate = true) var id: Long?,
|
||||||
@ColumnInfo(name = "widget_id") var widgetId: Int,
|
@ColumnInfo(name = "widget_id") var widgetId: Int,
|
||||||
@ColumnInfo(name = "note_id") var noteId: Long)
|
@ColumnInfo(name = "note_id") var noteId: Long)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user