Fix compilation issue and rename method

This commit is contained in:
ganfra 2018-10-19 14:26:13 +02:00
parent 0041b6273e
commit e323c858ab
4 changed files with 11 additions and 7 deletions

View File

@ -1,9 +1,13 @@
package im.vector.matrix.android.api.session.room

import android.arch.lifecycle.LiveData
import android.arch.paging.PagedList
import im.vector.matrix.android.api.session.events.model.Event

interface Room {

val roomId: String


fun liveTimeline(): LiveData<PagedList<Event>>

}

View File

@ -24,7 +24,7 @@ data class DefaultRoom(
private val monarchy by inject<Monarchy>()
private val boundaryCallback = TimelineBoundaryCallback(paginationRequest, roomId, monarchy, Executors.newSingleThreadExecutor())

fun events(): LiveData<PagedList<Event>> {
override fun liveTimeline(): LiveData<PagedList<Event>> {
val realmDataSourceFactory = monarchy.createDataSourceFactory { realm ->
val lastChunk = ChunkEntity.where(realm, roomId).findAll().last()
EventEntity.where(realm, lastChunk)

View File

@ -5,14 +5,14 @@ import com.zhuinden.monarchy.Monarchy
import im.vector.matrix.android.api.session.room.Room
import im.vector.matrix.android.api.session.room.RoomService
import im.vector.matrix.android.internal.database.model.RoomEntity
import im.vector.matrix.android.internal.database.query.find
import im.vector.matrix.android.internal.database.query.where

class DefaultRoomService(private val monarchy: Monarchy) : RoomService {

override fun getAllRooms(): List<Room> {
var rooms: List<Room> = emptyList()
monarchy.doWithRealm { realm ->
rooms = RoomEntity.find(realm).findAll().map { DefaultRoom(it.roomId) }
rooms = RoomEntity.where(realm).findAll().map { DefaultRoom(it.roomId) }
}
return rooms
}
@ -20,14 +20,14 @@ class DefaultRoomService(private val monarchy: Monarchy) : RoomService {
override fun getRoom(roomId: String): Room? {
var room: Room? = null
monarchy.doWithRealm { realm ->
room = RoomEntity.find(realm, roomId).findFirst()?.let { DefaultRoom(it.roomId) }
room = RoomEntity.where(realm, roomId).findFirst()?.let { DefaultRoom(it.roomId) }
}
return room
}

override fun rooms(): LiveData<List<Room>> {
return monarchy.findAllMappedWithChanges(
{ realm -> RoomEntity.find(realm) },
{ realm -> RoomEntity.where(realm) },
{ DefaultRoom(it.roomId) }
)
}

View File

@ -18,7 +18,7 @@ class RoomModule : Module {
}

scope(DefaultSession.SCOPE) {
PaginationRequest(get(), get())
PaginationRequest(get(), get(), get())
}
}.invoke()
}