Convert StickerManagementRepository to kotlin.

Converts `StickerManagementRepository` to kotlin, so `getStickerPacks()` can return a `Flow` that emits updates after the database is changed.

This change simplifies the implementation of `StickerManagmentViewModelV2`, since `StickerManagementRepository.getStickerPacks()` will now automatically register and unregister the database observer.
This commit is contained in:
Jeffrey Starke
2025-04-17 16:23:19 -04:00
committed by Cody Henthorne
parent 050dcb3eb1
commit 2cfe321274
8 changed files with 204 additions and 167 deletions

View File

@@ -305,7 +305,7 @@ class StickerTable(
notifyStickerListeners()
}
fun updatePackOrder(packsInOrder: MutableList<StickerPackRecord>) {
fun updatePackOrder(packsInOrder: List<StickerPackRecord>) {
writableDatabase.withinTransaction { db ->
for ((i, pack) in packsInOrder.withIndex()) {
db.update(TABLE_NAME)
@@ -470,6 +470,12 @@ class StickerTable(
)
}
fun asSequence(): Sequence<StickerPackRecord> = sequence {
while (getNext() != null) {
yield(getCurrent())
}
}
override fun close() {
cursor.close()
}