forked from GitHub-Mirror/riotX-android
Fix compilation issue and rename method
This commit is contained in:
parent
0041b6273e
commit
e323c858ab
@ -1,9 +1,13 @@
|
|||||||
package im.vector.matrix.android.api.session.room
|
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 {
|
interface Room {
|
||||||
|
|
||||||
val roomId: String
|
val roomId: String
|
||||||
|
|
||||||
|
fun liveTimeline(): LiveData<PagedList<Event>>
|
||||||
|
|
||||||
}
|
}
|
@ -24,7 +24,7 @@ data class DefaultRoom(
|
|||||||
private val monarchy by inject<Monarchy>()
|
private val monarchy by inject<Monarchy>()
|
||||||
private val boundaryCallback = TimelineBoundaryCallback(paginationRequest, roomId, monarchy, Executors.newSingleThreadExecutor())
|
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 realmDataSourceFactory = monarchy.createDataSourceFactory { realm ->
|
||||||
val lastChunk = ChunkEntity.where(realm, roomId).findAll().last()
|
val lastChunk = ChunkEntity.where(realm, roomId).findAll().last()
|
||||||
EventEntity.where(realm, lastChunk)
|
EventEntity.where(realm, lastChunk)
|
||||||
|
@ -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.Room
|
||||||
import im.vector.matrix.android.api.session.room.RoomService
|
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.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 {
|
class DefaultRoomService(private val monarchy: Monarchy) : RoomService {
|
||||||
|
|
||||||
override fun getAllRooms(): List<Room> {
|
override fun getAllRooms(): List<Room> {
|
||||||
var rooms: List<Room> = emptyList()
|
var rooms: List<Room> = emptyList()
|
||||||
monarchy.doWithRealm { realm ->
|
monarchy.doWithRealm { realm ->
|
||||||
rooms = RoomEntity.find(realm).findAll().map { DefaultRoom(it.roomId) }
|
rooms = RoomEntity.where(realm).findAll().map { DefaultRoom(it.roomId) }
|
||||||
}
|
}
|
||||||
return rooms
|
return rooms
|
||||||
}
|
}
|
||||||
@ -20,14 +20,14 @@ class DefaultRoomService(private val monarchy: Monarchy) : RoomService {
|
|||||||
override fun getRoom(roomId: String): Room? {
|
override fun getRoom(roomId: String): Room? {
|
||||||
var room: Room? = null
|
var room: Room? = null
|
||||||
monarchy.doWithRealm { realm ->
|
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
|
return room
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun rooms(): LiveData<List<Room>> {
|
override fun rooms(): LiveData<List<Room>> {
|
||||||
return monarchy.findAllMappedWithChanges(
|
return monarchy.findAllMappedWithChanges(
|
||||||
{ realm -> RoomEntity.find(realm) },
|
{ realm -> RoomEntity.where(realm) },
|
||||||
{ DefaultRoom(it.roomId) }
|
{ DefaultRoom(it.roomId) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ class RoomModule : Module {
|
|||||||
}
|
}
|
||||||
|
|
||||||
scope(DefaultSession.SCOPE) {
|
scope(DefaultSession.SCOPE) {
|
||||||
PaginationRequest(get(), get())
|
PaginationRequest(get(), get(), get())
|
||||||
}
|
}
|
||||||
}.invoke()
|
}.invoke()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user