2018-10-03 15:56:33 +00:00
|
|
|
package im.vector.riotredesign.features.home
|
|
|
|
|
|
|
|
import android.content.Context
|
|
|
|
import android.content.Intent
|
|
|
|
import android.os.Bundle
|
2018-10-08 15:52:45 +00:00
|
|
|
import im.vector.matrix.android.api.Matrix
|
2018-10-16 13:52:30 +00:00
|
|
|
import im.vector.matrix.android.internal.database.model.RoomSummaryEntity
|
2018-10-03 15:56:33 +00:00
|
|
|
import im.vector.riotredesign.R
|
|
|
|
import im.vector.riotredesign.core.platform.RiotActivity
|
2018-10-08 15:52:45 +00:00
|
|
|
import kotlinx.android.synthetic.main.activity_home.*
|
|
|
|
import org.koin.android.ext.android.inject
|
2018-10-16 13:52:30 +00:00
|
|
|
import timber.log.Timber
|
2018-10-03 15:56:33 +00:00
|
|
|
|
2018-10-17 11:59:21 +00:00
|
|
|
|
2018-10-03 15:56:33 +00:00
|
|
|
class HomeActivity : RiotActivity() {
|
|
|
|
|
2018-10-08 15:52:45 +00:00
|
|
|
private val matrix by inject<Matrix>()
|
2018-10-17 11:59:21 +00:00
|
|
|
private val currentSession = matrix.currentSession!!
|
|
|
|
private val realmHolder = currentSession.realmHolder()
|
|
|
|
private val syncThread = currentSession.syncThread()
|
2018-10-08 15:52:45 +00:00
|
|
|
|
2018-10-03 15:56:33 +00:00
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
|
super.onCreate(savedInstanceState)
|
|
|
|
setContentView(R.layout.activity_home)
|
2018-10-17 11:59:21 +00:00
|
|
|
val results = realmHolder.instance.where(RoomSummaryEntity::class.java).findAll()
|
|
|
|
results.addChangeListener { summaries ->
|
|
|
|
Timber.v("Summaries updated")
|
2018-10-15 17:42:13 +00:00
|
|
|
}
|
2018-10-17 11:59:21 +00:00
|
|
|
startSyncButton.setOnClickListener { syncThread.restart() }
|
|
|
|
stopSyncButton.setOnClickListener { syncThread.pause() }
|
2018-10-03 15:56:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
companion object {
|
|
|
|
fun newIntent(context: Context): Intent {
|
|
|
|
return Intent(context, HomeActivity::class.java)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|