mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-22 01:15:54 +03:00
Clean some files
This commit is contained in:
parent
00188fde29
commit
1646687e6d
6 changed files with 14 additions and 28 deletions
|
@ -1,13 +1,13 @@
|
|||
package im.vector.riotredesign.features.home
|
||||
|
||||
import android.arch.lifecycle.Observer
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import im.vector.matrix.android.api.Matrix
|
||||
import im.vector.matrix.android.internal.database.model.RoomSummaryEntity
|
||||
import im.vector.matrix.android.api.session.room.Room
|
||||
import im.vector.riotredesign.R
|
||||
import im.vector.riotredesign.core.platform.RiotActivity
|
||||
import kotlinx.android.synthetic.main.activity_home.*
|
||||
import org.koin.android.ext.android.inject
|
||||
import timber.log.Timber
|
||||
|
||||
|
@ -16,18 +16,16 @@ class HomeActivity : RiotActivity() {
|
|||
|
||||
private val matrix by inject<Matrix>()
|
||||
private val currentSession = matrix.currentSession!!
|
||||
private val realmHolder = currentSession.realmHolder()
|
||||
private val syncThread = currentSession.syncThread()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_home)
|
||||
val results = realmHolder.instance.where(RoomSummaryEntity::class.java).findAll()
|
||||
results.addChangeListener { summaries ->
|
||||
Timber.v("Summaries updated")
|
||||
}
|
||||
startSyncButton.setOnClickListener { syncThread.restart() }
|
||||
stopSyncButton.setOnClickListener { syncThread.pause() }
|
||||
currentSession.rooms().observe(this, Observer<List<Room>> { roomList ->
|
||||
if (roomList == null) {
|
||||
return@Observer
|
||||
}
|
||||
Timber.v("Observe rooms: %d", roomList.size)
|
||||
})
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -13,9 +13,4 @@ interface Session : RoomService {
|
|||
@MainThread
|
||||
fun close()
|
||||
|
||||
fun syncThread(): SyncThread
|
||||
|
||||
// Visible for testing request directly. Will be deleted
|
||||
fun realmHolder(): SessionRealmHolder
|
||||
|
||||
}
|
|
@ -4,4 +4,6 @@ interface Room {
|
|||
|
||||
val roomId: String
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -8,6 +8,6 @@ interface RoomService {
|
|||
|
||||
fun getAllRooms(): List<Room>
|
||||
|
||||
fun observeAllRooms(): LiveData<List<Room>>
|
||||
fun rooms(): LiveData<List<Room>>
|
||||
|
||||
}
|
|
@ -47,15 +47,6 @@ class DefaultSession(private val sessionParams: SessionParams
|
|||
syncThread.start()
|
||||
}
|
||||
|
||||
override fun realmHolder(): SessionRealmHolder {
|
||||
assert(isOpen)
|
||||
return realmInstanceHolder
|
||||
}
|
||||
|
||||
override fun syncThread(): SyncThread {
|
||||
assert(isOpen)
|
||||
return syncThread
|
||||
}
|
||||
|
||||
@MainThread
|
||||
override fun close() {
|
||||
|
@ -78,8 +69,8 @@ class DefaultSession(private val sessionParams: SessionParams
|
|||
return roomService.getAllRooms()
|
||||
}
|
||||
|
||||
override fun observeAllRooms(): LiveData<List<Room>> {
|
||||
return roomService.observeAllRooms()
|
||||
override fun rooms(): LiveData<List<Room>> {
|
||||
return roomService.rooms()
|
||||
}
|
||||
|
||||
// Private methods *****************************************************************************
|
||||
|
|
|
@ -29,7 +29,7 @@ class DefaultRoomService(private val realmConfiguration: RealmConfiguration,
|
|||
return room
|
||||
}
|
||||
|
||||
override fun observeAllRooms(): LiveData<List<Room>> {
|
||||
override fun rooms(): LiveData<List<Room>> {
|
||||
val roomResults = RoomEntity.getAll(mainThreadRealm.instance).findAllAsync()
|
||||
return RealmLiveData(roomResults) { DefaultRoom(it.roomId) }
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue