mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 17:29:32 +01:00
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:
committed by
Cody Henthorne
parent
050dcb3eb1
commit
2cfe321274
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user