From 34e08705ddc3cb8541000841b425b1c3b9f2755d Mon Sep 17 00:00:00 2001 From: ganfra Date: Sat, 12 Jan 2019 10:33:39 +0100 Subject: [PATCH] Timeline : still trying to adjust PagedList options --- .../session/room/timeline/DefaultTimelineService.kt | 6 +++--- .../room/timeline/TimelineBoundaryCallback.kt | 13 +++++-------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/DefaultTimelineService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/DefaultTimelineService.kt index 5ce44682aa..6f5a80ad6b 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/DefaultTimelineService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/DefaultTimelineService.kt @@ -22,8 +22,8 @@ import im.vector.matrix.android.internal.util.tryTransactionAsync import io.realm.Realm import io.realm.RealmQuery -private const val PAGE_SIZE = 120 -private const val PREFETCH_DISTANCE = 40 +private const val PAGE_SIZE = 100 +private const val PREFETCH_DISTANCE = 30 private const val EVENT_NOT_FOUND_INDEX = -1 internal class DefaultTimelineService(private val roomId: String, @@ -60,7 +60,7 @@ internal class DefaultTimelineService(private val roomId: String, val pagedListConfig = PagedList.Config.Builder() .setEnablePlaceholders(false) .setPageSize(PAGE_SIZE) - .setInitialLoadSizeHint(PAGE_SIZE) + .setInitialLoadSizeHint(2 * PAGE_SIZE) .setPrefetchDistance(PREFETCH_DISTANCE) .build() diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/TimelineBoundaryCallback.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/TimelineBoundaryCallback.kt index db9617e094..2ce550f337 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/TimelineBoundaryCallback.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/TimelineBoundaryCallback.kt @@ -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.configureWith import im.vector.matrix.android.internal.util.PagingRequestHelper -import timber.log.Timber internal class TimelineBoundaryCallback(private val roomId: String, private val taskExecutor: TaskExecutor, @@ -43,22 +42,20 @@ internal class TimelineBoundaryCallback(private val roomId: String, } override fun onItemAtEndLoaded(itemAtEnd: EnrichedEvent) { - Timber.v("On item at end loaded") val token = itemAtEnd.root.eventId?.let { getToken(it, PaginationDirection.BACKWARDS) } ?: return helper.runIfNotRunning(PagingRequestHelper.RequestType.AFTER) { - runPaginationRequest(it, token, PaginationDirection.BACKWARDS) + executePaginationTask(it, token, PaginationDirection.BACKWARDS) } } override fun onItemAtFrontLoaded(itemAtFront: EnrichedEvent) { - Timber.v("On item at front loaded") val token = itemAtFront.root.eventId?.let { getToken(it, PaginationDirection.FORWARDS) } ?: return 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 } - private fun runPaginationRequest(requestCallback: PagingRequestHelper.Request.Callback, - from: String, - direction: PaginationDirection) { + private fun executePaginationTask(requestCallback: PagingRequestHelper.Request.Callback, + from: String, + direction: PaginationDirection) { val params = PaginationTask.Params(roomId = roomId, from = from,