mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-25 10:55:55 +03:00
Timeline : still trying to adjust PagedList options
This commit is contained in:
parent
acf2301fc9
commit
34e08705dd
2 changed files with 8 additions and 11 deletions
|
@ -22,8 +22,8 @@ import im.vector.matrix.android.internal.util.tryTransactionAsync
|
||||||
import io.realm.Realm
|
import io.realm.Realm
|
||||||
import io.realm.RealmQuery
|
import io.realm.RealmQuery
|
||||||
|
|
||||||
private const val PAGE_SIZE = 120
|
private const val PAGE_SIZE = 100
|
||||||
private const val PREFETCH_DISTANCE = 40
|
private const val PREFETCH_DISTANCE = 30
|
||||||
private const val EVENT_NOT_FOUND_INDEX = -1
|
private const val EVENT_NOT_FOUND_INDEX = -1
|
||||||
|
|
||||||
internal class DefaultTimelineService(private val roomId: String,
|
internal class DefaultTimelineService(private val roomId: String,
|
||||||
|
@ -60,7 +60,7 @@ internal class DefaultTimelineService(private val roomId: String,
|
||||||
val pagedListConfig = PagedList.Config.Builder()
|
val pagedListConfig = PagedList.Config.Builder()
|
||||||
.setEnablePlaceholders(false)
|
.setEnablePlaceholders(false)
|
||||||
.setPageSize(PAGE_SIZE)
|
.setPageSize(PAGE_SIZE)
|
||||||
.setInitialLoadSizeHint(PAGE_SIZE)
|
.setInitialLoadSizeHint(2 * PAGE_SIZE)
|
||||||
.setPrefetchDistance(PREFETCH_DISTANCE)
|
.setPrefetchDistance(PREFETCH_DISTANCE)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ import im.vector.matrix.android.internal.database.query.findIncludingEvent
|
||||||
import im.vector.matrix.android.internal.task.TaskExecutor
|
import im.vector.matrix.android.internal.task.TaskExecutor
|
||||||
import im.vector.matrix.android.internal.task.configureWith
|
import im.vector.matrix.android.internal.task.configureWith
|
||||||
import im.vector.matrix.android.internal.util.PagingRequestHelper
|
import im.vector.matrix.android.internal.util.PagingRequestHelper
|
||||||
import timber.log.Timber
|
|
||||||
|
|
||||||
internal class TimelineBoundaryCallback(private val roomId: String,
|
internal class TimelineBoundaryCallback(private val roomId: String,
|
||||||
private val taskExecutor: TaskExecutor,
|
private val taskExecutor: TaskExecutor,
|
||||||
|
@ -43,22 +42,20 @@ internal class TimelineBoundaryCallback(private val roomId: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onItemAtEndLoaded(itemAtEnd: EnrichedEvent) {
|
override fun onItemAtEndLoaded(itemAtEnd: EnrichedEvent) {
|
||||||
Timber.v("On item at end loaded")
|
|
||||||
val token = itemAtEnd.root.eventId?.let { getToken(it, PaginationDirection.BACKWARDS) }
|
val token = itemAtEnd.root.eventId?.let { getToken(it, PaginationDirection.BACKWARDS) }
|
||||||
?: return
|
?: return
|
||||||
|
|
||||||
helper.runIfNotRunning(PagingRequestHelper.RequestType.AFTER) {
|
helper.runIfNotRunning(PagingRequestHelper.RequestType.AFTER) {
|
||||||
runPaginationRequest(it, token, PaginationDirection.BACKWARDS)
|
executePaginationTask(it, token, PaginationDirection.BACKWARDS)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onItemAtFrontLoaded(itemAtFront: EnrichedEvent) {
|
override fun onItemAtFrontLoaded(itemAtFront: EnrichedEvent) {
|
||||||
Timber.v("On item at front loaded")
|
|
||||||
val token = itemAtFront.root.eventId?.let { getToken(it, PaginationDirection.FORWARDS) }
|
val token = itemAtFront.root.eventId?.let { getToken(it, PaginationDirection.FORWARDS) }
|
||||||
?: return
|
?: return
|
||||||
|
|
||||||
helper.runIfNotRunning(PagingRequestHelper.RequestType.BEFORE) {
|
helper.runIfNotRunning(PagingRequestHelper.RequestType.BEFORE) {
|
||||||
runPaginationRequest(it, token, PaginationDirection.FORWARDS)
|
executePaginationTask(it, token, PaginationDirection.FORWARDS)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,9 +68,9 @@ internal class TimelineBoundaryCallback(private val roomId: String,
|
||||||
return token
|
return token
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun runPaginationRequest(requestCallback: PagingRequestHelper.Request.Callback,
|
private fun executePaginationTask(requestCallback: PagingRequestHelper.Request.Callback,
|
||||||
from: String,
|
from: String,
|
||||||
direction: PaginationDirection) {
|
direction: PaginationDirection) {
|
||||||
|
|
||||||
val params = PaginationTask.Params(roomId = roomId,
|
val params = PaginationTask.Params(roomId = roomId,
|
||||||
from = from,
|
from = from,
|
||||||
|
|
Loading…
Reference in a new issue