Use epoxy to render pagedList : WIP

This commit is contained in:
ganfra
2018-10-19 15:30:40 +02:00
parent 06a5253fd9
commit ecbc64082f
20 changed files with 239 additions and 17 deletions

View File

@ -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? {

View File

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