Timeline : still trying to adjust PagedList options

This commit is contained in:
ganfra 2019-01-12 10:33:39 +01:00 committed by ganfra
parent acf2301fc9
commit 34e08705dd
2 changed files with 8 additions and 11 deletions

View File

@ -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()

View File

@ -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,