forked from GitHub-Mirror/riotX-android
Use epoxy to render pagedList : WIP
This commit is contained in:
@ -11,11 +11,11 @@ fun EventEntity.Companion.where(realm: Realm, roomId: String): RealmQuery<EventE
|
||||
.equalTo("chunk.room.roomId", roomId)
|
||||
}
|
||||
|
||||
fun EventEntity.Companion.where(realm: Realm, chunk: ChunkEntity?): RealmQuery<EventEntity> {
|
||||
fun EventEntity.Companion.where(realm: Realm, chunk: ChunkEntity): RealmQuery<EventEntity> {
|
||||
return realm.where(EventEntity::class.java)
|
||||
.equalTo("chunk.prevToken", chunk?.prevToken)
|
||||
.equalTo("chunk.prevToken", chunk.prevToken)
|
||||
.and()
|
||||
.equalTo("chunk.nextToken", chunk?.nextToken)
|
||||
.equalTo("chunk.nextToken", chunk.nextToken)
|
||||
}
|
||||
|
||||
fun RealmResults<EventEntity>.getLast(type: String? = null): EventEntity? {
|
||||
|
@ -27,7 +27,11 @@ data class DefaultRoom(
|
||||
override fun liveTimeline(): LiveData<PagedList<Event>> {
|
||||
val realmDataSourceFactory = monarchy.createDataSourceFactory { realm ->
|
||||
val lastChunk = ChunkEntity.where(realm, roomId).findAll().last()
|
||||
EventEntity.where(realm, lastChunk)
|
||||
if (lastChunk == null) {
|
||||
EventEntity.where(realm, roomId)
|
||||
} else {
|
||||
EventEntity.where(realm, lastChunk)
|
||||
}
|
||||
}
|
||||
val domainSourceFactory = realmDataSourceFactory.map { EventMapper.map(it) }
|
||||
val livePagedListBuilder = LivePagedListBuilder(domainSourceFactory, 20).setBoundaryCallback(boundaryCallback)
|
||||
|
Reference in New Issue
Block a user