forked from GitHub-Mirror/riotX-android
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 im.vector.matrix.android.internal.session.events.interceptor.MessageEventInterceptor
|
||||||
import io.realm.Sort
|
import io.realm.Sort
|
||||||
|
|
||||||
|
private const val PAGE_SIZE = 30
|
||||||
|
|
||||||
class DefaultTimelineHolder(private val roomId: String,
|
class DefaultTimelineHolder(private val roomId: String,
|
||||||
private val monarchy: Monarchy,
|
private val monarchy: Monarchy,
|
||||||
private val boundaryCallback: TimelineBoundaryCallback
|
private val boundaryCallback: TimelineBoundaryCallback
|
||||||
@ -22,6 +24,7 @@ class DefaultTimelineHolder(private val roomId: String,
|
|||||||
private val eventInterceptors = ArrayList<EnrichedEventInterceptor>()
|
private val eventInterceptors = ArrayList<EnrichedEventInterceptor>()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
boundaryCallback.limit = PAGE_SIZE
|
||||||
eventInterceptors.add(MessageEventInterceptor(monarchy))
|
eventInterceptors.add(MessageEventInterceptor(monarchy))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,6 +40,7 @@ class DefaultTimelineHolder(private val roomId: String,
|
|||||||
val domainSourceFactory = realmDataSourceFactory
|
val domainSourceFactory = realmDataSourceFactory
|
||||||
.map { it.asDomain() }
|
.map { it.asDomain() }
|
||||||
.map { event ->
|
.map { event ->
|
||||||
|
|
||||||
val enrichedEvent = EnrichedEvent(event)
|
val enrichedEvent = EnrichedEvent(event)
|
||||||
eventInterceptors
|
eventInterceptors
|
||||||
.filter {
|
.filter {
|
||||||
@ -49,7 +53,7 @@ class DefaultTimelineHolder(private val roomId: String,
|
|||||||
|
|
||||||
val pagedListConfig = PagedList.Config.Builder()
|
val pagedListConfig = PagedList.Config.Builder()
|
||||||
.setEnablePlaceholders(false)
|
.setEnablePlaceholders(false)
|
||||||
.setPageSize(10)
|
.setPageSize(PAGE_SIZE)
|
||||||
.setPrefetchDistance(10)
|
.setPrefetchDistance(10)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
|
@ -19,6 +19,8 @@ class TimelineBoundaryCallback(private val roomId: String,
|
|||||||
|
|
||||||
private val helper = PagingRequestHelper(ioExecutor)
|
private val helper = PagingRequestHelper(ioExecutor)
|
||||||
|
|
||||||
|
var limit = 10
|
||||||
|
|
||||||
override fun onZeroItemsLoaded() {
|
override fun onZeroItemsLoaded() {
|
||||||
// actually, it's not possible
|
// actually, it's not possible
|
||||||
}
|
}
|
||||||
@ -30,7 +32,7 @@ class TimelineBoundaryCallback(private val roomId: String,
|
|||||||
return@doWithRealm
|
return@doWithRealm
|
||||||
}
|
}
|
||||||
val chunkEntity = ChunkEntity.findAllIncludingEvents(realm, Collections.singletonList(itemAtEnd.root.eventId)).firstOrNull()
|
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
|
return@doWithRealm
|
||||||
}
|
}
|
||||||
val chunkEntity = ChunkEntity.findAllIncludingEvents(realm, Collections.singletonList(itemAtFront.root.eventId)).firstOrNull()
|
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