mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-12-22 23:58:47 +01:00
Timeline : change page size
This commit is contained in:
parent
900217b90e
commit
536d7c33fe
@ -14,6 +14,8 @@ import im.vector.matrix.android.internal.database.query.where
|
||||
import im.vector.matrix.android.internal.session.events.interceptor.MessageEventInterceptor
|
||||
import io.realm.Sort
|
||||
|
||||
private const val PAGE_SIZE = 30
|
||||
|
||||
class DefaultTimelineHolder(private val roomId: String,
|
||||
private val monarchy: Monarchy,
|
||||
private val boundaryCallback: TimelineBoundaryCallback
|
||||
@ -22,6 +24,7 @@ class DefaultTimelineHolder(private val roomId: String,
|
||||
private val eventInterceptors = ArrayList<EnrichedEventInterceptor>()
|
||||
|
||||
init {
|
||||
boundaryCallback.limit = PAGE_SIZE
|
||||
eventInterceptors.add(MessageEventInterceptor(monarchy))
|
||||
}
|
||||
|
||||
@ -37,6 +40,7 @@ class DefaultTimelineHolder(private val roomId: String,
|
||||
val domainSourceFactory = realmDataSourceFactory
|
||||
.map { it.asDomain() }
|
||||
.map { event ->
|
||||
|
||||
val enrichedEvent = EnrichedEvent(event)
|
||||
eventInterceptors
|
||||
.filter {
|
||||
@ -49,7 +53,7 @@ class DefaultTimelineHolder(private val roomId: String,
|
||||
|
||||
val pagedListConfig = PagedList.Config.Builder()
|
||||
.setEnablePlaceholders(false)
|
||||
.setPageSize(10)
|
||||
.setPageSize(PAGE_SIZE)
|
||||
.setPrefetchDistance(10)
|
||||
.build()
|
||||
|
||||
|
@ -19,6 +19,8 @@ class TimelineBoundaryCallback(private val roomId: String,
|
||||
|
||||
private val helper = PagingRequestHelper(ioExecutor)
|
||||
|
||||
var limit = 10
|
||||
|
||||
override fun onZeroItemsLoaded() {
|
||||
// actually, it's not possible
|
||||
}
|
||||
@ -30,7 +32,7 @@ class TimelineBoundaryCallback(private val roomId: String,
|
||||
return@doWithRealm
|
||||
}
|
||||
val chunkEntity = ChunkEntity.findAllIncludingEvents(realm, Collections.singletonList(itemAtEnd.root.eventId)).firstOrNull()
|
||||
paginationRequest.execute(roomId, chunkEntity?.prevToken, PaginationDirection.BACKWARDS, callback = createCallback(it))
|
||||
paginationRequest.execute(roomId, chunkEntity?.prevToken, PaginationDirection.BACKWARDS, limit, callback = createCallback(it))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -42,7 +44,7 @@ class TimelineBoundaryCallback(private val roomId: String,
|
||||
return@doWithRealm
|
||||
}
|
||||
val chunkEntity = ChunkEntity.findAllIncludingEvents(realm, Collections.singletonList(itemAtFront.root.eventId)).firstOrNull()
|
||||
paginationRequest.execute(roomId, chunkEntity?.nextToken, PaginationDirection.FORWARDS, callback = createCallback(it))
|
||||
paginationRequest.execute(roomId, chunkEntity?.nextToken, PaginationDirection.FORWARDS, limit, callback = createCallback(it))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user