mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 02:05:06 +08:00
Insert room shortcuts in order
This prevents shortcuts from momentarily being shown out of order while the shortcut list is in the process of being updated.
This commit is contained in:
parent
842ccb12b2
commit
2004d357d5
@ -58,7 +58,7 @@ class ShortcutCreator @Inject constructor(
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
fun create(roomSummary: RoomSummary): ShortcutInfoCompat {
|
||||
fun create(roomSummary: RoomSummary, rank: Int = 1): ShortcutInfoCompat {
|
||||
val intent = RoomDetailActivity.shortcutIntent(context, roomSummary.roomId)
|
||||
val bitmap = try {
|
||||
avatarRenderer.shortcutDrawable(GlideApp.with(context), roomSummary.toMatrixItem(), iconSize)
|
||||
@ -70,6 +70,7 @@ class ShortcutCreator @Inject constructor(
|
||||
.setIcon(bitmap?.toProfileImageIcon())
|
||||
.setIntent(intent)
|
||||
.setLongLived(true)
|
||||
.setRank(rank)
|
||||
|
||||
// Make it show up in the direct share menu
|
||||
.setCategories(setOf(
|
||||
|
@ -58,9 +58,9 @@ class ShortcutsHandler @Inject constructor(
|
||||
.filter { !roomIds.contains(it) }
|
||||
ShortcutManagerCompat.removeLongLivedShortcuts(context, deadShortcutIds)
|
||||
|
||||
val shortcuts = rooms
|
||||
.asReversed()
|
||||
.map { shortcutCreator.create(it) }
|
||||
val shortcuts = rooms.mapIndexed { index, room ->
|
||||
shortcutCreator.create(room, index)
|
||||
}
|
||||
|
||||
shortcuts.forEach { shortcut ->
|
||||
ShortcutManagerCompat.pushDynamicShortcut(context, shortcut)
|
||||
|
Loading…
Reference in New Issue
Block a user