mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 10:25:35 +03:00
Timeline: add a prefetch backward item
This commit is contained in:
parent
435724ffa9
commit
3f5b1083f3
1 changed files with 15 additions and 0 deletions
|
@ -116,6 +116,7 @@ class TimelineEventController @Inject constructor(private val dateFormatter: Vec
|
|||
private var unreadState: UnreadState = UnreadState.Unknown
|
||||
private var positionOfReadMarker: Int? = null
|
||||
private var eventIdToHighlight: String? = null
|
||||
private var previousModelsSize = 0
|
||||
|
||||
var callback: Callback? = null
|
||||
var timeline: Timeline? = null
|
||||
|
@ -191,6 +192,20 @@ class TimelineEventController @Inject constructor(private val dateFormatter: Vec
|
|||
models.add(position, readMarker)
|
||||
}
|
||||
}
|
||||
val shouldAdd = timeline?.hasMoreToLoad(Timeline.Direction.BACKWARDS) ?: false
|
||||
if (shouldAdd) {
|
||||
val indexOfPrefetchBackward = (previousModelsSize - 1)
|
||||
.coerceAtLeast(0)
|
||||
.coerceAtMost(models.size - 1)
|
||||
|
||||
val loadingItem = LoadingItem_()
|
||||
.id("prefetch_backward_loading${System.currentTimeMillis()}")
|
||||
.showLoader(false)
|
||||
.setVisibilityStateChangedListener(Timeline.Direction.BACKWARDS)
|
||||
|
||||
models.add(indexOfPrefetchBackward, loadingItem)
|
||||
}
|
||||
previousModelsSize = models.size
|
||||
}
|
||||
|
||||
fun update(viewState: RoomDetailViewState) {
|
||||
|
|
Loading…
Reference in a new issue