diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser
index 4859402ac0..0636ad2de7 100644
Binary files a/.idea/caches/build_file_checksums.ser and b/.idea/caches/build_file_checksums.ser differ
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 35d2fcd030..004dc06695 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -10,7 +10,7 @@
-
+
diff --git a/app/build.gradle b/app/build.gradle
index 5b1073c05c..963750b832 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -41,6 +41,7 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(":matrix-sdk-android")
+ implementation project(":matrix-sdk-android-rx")
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
@@ -51,11 +52,11 @@ dependencies {
implementation("com.airbnb.android:epoxy:$epoxy_version")
kapt "com.airbnb.android:epoxy-processor:$epoxy_version"
implementation "com.airbnb.android:epoxy-paging:$epoxy_version"
+ implementation 'com.airbnb.android:mvrx:0.6.0'
implementation "org.koin:koin-android:$koin_version"
implementation "org.koin:koin-android-scope:$koin_version"
- implementation "org.koin:koin-android-viewmodel:$koin_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
diff --git a/app/src/main/java/im/vector/riotredesign/core/platform/CheckableConstraintLayout.kt b/app/src/main/java/im/vector/riotredesign/core/platform/CheckableConstraintLayout.kt
new file mode 100644
index 0000000000..967c0a8c0b
--- /dev/null
+++ b/app/src/main/java/im/vector/riotredesign/core/platform/CheckableConstraintLayout.kt
@@ -0,0 +1,45 @@
+package im.vector.riotredesign.core.platform
+
+import android.content.Context
+import android.support.constraint.ConstraintLayout
+import android.util.AttributeSet
+import android.view.View
+import android.widget.Checkable
+
+class CheckableConstraintLayout : ConstraintLayout, Checkable {
+
+ private var mChecked = false
+
+ constructor(context: Context) : super(context) {}
+
+ constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {}
+
+ constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {}
+
+ override fun isChecked(): Boolean {
+ return mChecked
+ }
+
+ override fun setChecked(b: Boolean) {
+ if (b != mChecked) {
+ mChecked = b
+ refreshDrawableState()
+ }
+ }
+
+ override fun toggle() {
+ isChecked = !mChecked
+ }
+
+ public override fun onCreateDrawableState(extraSpace: Int): IntArray {
+ val drawableState = super.onCreateDrawableState(extraSpace + 1)
+ if (isChecked) {
+ View.mergeDrawableStates(drawableState, CHECKED_STATE_SET)
+ }
+ return drawableState
+ }
+
+ companion object {
+ private val CHECKED_STATE_SET = intArrayOf(android.R.attr.state_checked)
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/im/vector/riotredesign/core/platform/RiotActivity.kt b/app/src/main/java/im/vector/riotredesign/core/platform/RiotActivity.kt
index d6e3ccb200..1308a0e12c 100644
--- a/app/src/main/java/im/vector/riotredesign/core/platform/RiotActivity.kt
+++ b/app/src/main/java/im/vector/riotredesign/core/platform/RiotActivity.kt
@@ -1,7 +1,5 @@
package im.vector.riotredesign.core.platform
-import android.support.v7.app.AppCompatActivity
+import com.airbnb.mvrx.BaseMvRxActivity
-open class RiotActivity : AppCompatActivity() {
-
-}
\ No newline at end of file
+abstract class RiotActivity : BaseMvRxActivity()
\ No newline at end of file
diff --git a/app/src/main/java/im/vector/riotredesign/core/platform/RiotFragment.kt b/app/src/main/java/im/vector/riotredesign/core/platform/RiotFragment.kt
index 4006055b7c..3f5e3d8618 100644
--- a/app/src/main/java/im/vector/riotredesign/core/platform/RiotFragment.kt
+++ b/app/src/main/java/im/vector/riotredesign/core/platform/RiotFragment.kt
@@ -1,6 +1,12 @@
package im.vector.riotredesign.core.platform
-import android.support.v4.app.Fragment
+import com.airbnb.mvrx.BaseMvRxFragment
+
+abstract class RiotFragment : BaseMvRxFragment() {
+
+ override fun invalidate() {
+ //no-ops by default
+ }
+
-open class RiotFragment : Fragment() {
}
\ No newline at end of file
diff --git a/app/src/main/java/im/vector/riotredesign/core/platform/StateView.kt b/app/src/main/java/im/vector/riotredesign/core/platform/StateView.kt
new file mode 100755
index 0000000000..e9f1cdf033
--- /dev/null
+++ b/app/src/main/java/im/vector/riotredesign/core/platform/StateView.kt
@@ -0,0 +1,81 @@
+package im.vector.riotredesign.core.platform
+
+import android.content.Context
+import android.util.AttributeSet
+import android.view.View
+import android.view.ViewGroup
+import android.widget.FrameLayout
+import im.vector.riotredesign.R
+import kotlinx.android.synthetic.main.view_state.view.*
+
+class StateView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0)
+ : FrameLayout(context, attrs, defStyle) {
+
+ sealed class State {
+ object Content : State()
+ object Loading : State()
+ data class Empty(val message: CharSequence? = null) : State()
+ data class Error(val message: CharSequence? = null) : State()
+ }
+
+
+ private var eventCallback: EventCallback? = null
+
+ var contentView: View? = null
+
+ var state: State = State.Empty()
+ set(newState) {
+ if (newState != state) {
+ update(newState)
+ }
+ }
+
+ interface EventCallback {
+ fun onRetryClicked()
+ }
+
+ init {
+ View.inflate(context, R.layout.view_state, this)
+ layoutParams = FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
+ errorRetryView.setOnClickListener {
+ eventCallback?.onRetryClicked()
+ }
+ state = State.Content
+ }
+
+
+ private fun update(newState: State) {
+ when (newState) {
+ is StateView.State.Content -> {
+ progressBar.visibility = View.INVISIBLE
+ errorView.visibility = View.INVISIBLE
+ emptyView.visibility = View.INVISIBLE
+ contentView?.visibility = View.VISIBLE
+ }
+ is StateView.State.Loading -> {
+ progressBar.visibility = View.VISIBLE
+ errorView.visibility = View.INVISIBLE
+ emptyView.visibility = View.INVISIBLE
+ contentView?.visibility = View.INVISIBLE
+ }
+ is StateView.State.Empty -> {
+ progressBar.visibility = View.INVISIBLE
+ errorView.visibility = View.INVISIBLE
+ emptyView.visibility = View.VISIBLE
+ emptyMessageView.text = newState.message
+ if (contentView != null) {
+ contentView!!.visibility = View.INVISIBLE
+ }
+ }
+ is StateView.State.Error -> {
+ progressBar.visibility = View.INVISIBLE
+ errorView.visibility = View.VISIBLE
+ emptyView.visibility = View.INVISIBLE
+ errorMessageView.text = newState.message
+ if (contentView != null) {
+ contentView!!.visibility = View.INVISIBLE
+ }
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/im/vector/riotredesign/features/home/HomeActivity.kt b/app/src/main/java/im/vector/riotredesign/features/home/HomeActivity.kt
index 05598e8efe..62abf6f20c 100644
--- a/app/src/main/java/im/vector/riotredesign/features/home/HomeActivity.kt
+++ b/app/src/main/java/im/vector/riotredesign/features/home/HomeActivity.kt
@@ -3,23 +3,37 @@ package im.vector.riotredesign.features.home
import android.content.Context
import android.content.Intent
import android.os.Bundle
+import android.view.Gravity
import im.vector.riotredesign.R
import im.vector.riotredesign.core.extensions.replaceFragment
import im.vector.riotredesign.core.platform.RiotActivity
+import im.vector.riotredesign.features.home.detail.LoadingRoomDetailFragment
+import im.vector.riotredesign.features.home.detail.RoomDetailFragment
+import im.vector.riotredesign.features.home.list.RoomListFragment
+import kotlinx.android.synthetic.main.activity_home.*
+import org.koin.standalone.StandAloneContext.loadKoinModules
-class HomeActivity : RiotActivity() {
+class HomeActivity : RiotActivity(), HomeNavigator {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_home)
-
+ loadKoinModules(listOf(HomeModule(this)))
if (savedInstanceState == null) {
val roomListFragment = RoomListFragment.newInstance()
- replaceFragment(roomListFragment, R.id.homeFragmentContainer)
+ val loadingDetail = LoadingRoomDetailFragment.newInstance()
+ replaceFragment(loadingDetail, R.id.homeDetailFragmentContainer)
+ replaceFragment(roomListFragment, R.id.homeDrawerFragmentContainer)
}
}
+ override fun openRoomDetail(roomId: String) {
+ val roomDetailFragment = RoomDetailFragment.newInstance(roomId)
+ replaceFragment(roomDetailFragment, R.id.homeDetailFragmentContainer)
+ drawerLayout.closeDrawer(Gravity.LEFT)
+ }
+
companion object {
fun newIntent(context: Context): Intent {
return Intent(context, HomeActivity::class.java)
diff --git a/app/src/main/java/im/vector/riotredesign/features/home/HomeModule.kt b/app/src/main/java/im/vector/riotredesign/features/home/HomeModule.kt
new file mode 100644
index 0000000000..0c8cf539b2
--- /dev/null
+++ b/app/src/main/java/im/vector/riotredesign/features/home/HomeModule.kt
@@ -0,0 +1,16 @@
+package im.vector.riotredesign.features.home
+
+import org.koin.dsl.context.ModuleDefinition
+import org.koin.dsl.module.Module
+import org.koin.dsl.module.module
+
+class HomeModule(private val homeActivity: HomeActivity) : Module {
+
+ override fun invoke(): ModuleDefinition = module(override = true) {
+
+ factory {
+ homeActivity as HomeNavigator
+ }
+
+ }.invoke()
+}
\ No newline at end of file
diff --git a/app/src/main/java/im/vector/riotredesign/features/home/HomeNavigator.kt b/app/src/main/java/im/vector/riotredesign/features/home/HomeNavigator.kt
new file mode 100644
index 0000000000..1b4382f1a9
--- /dev/null
+++ b/app/src/main/java/im/vector/riotredesign/features/home/HomeNavigator.kt
@@ -0,0 +1,7 @@
+package im.vector.riotredesign.features.home
+
+interface HomeNavigator {
+
+ fun openRoomDetail(roomId: String)
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/im/vector/riotredesign/features/home/RoomListFragment.kt b/app/src/main/java/im/vector/riotredesign/features/home/RoomListFragment.kt
deleted file mode 100644
index eb0b6a611d..0000000000
--- a/app/src/main/java/im/vector/riotredesign/features/home/RoomListFragment.kt
+++ /dev/null
@@ -1,51 +0,0 @@
-package im.vector.riotredesign.features.home
-
-import android.arch.lifecycle.Observer
-import android.os.Bundle
-import android.view.LayoutInflater
-import android.view.View
-import android.view.ViewGroup
-import im.vector.matrix.android.api.Matrix
-import im.vector.matrix.android.api.session.room.model.RoomSummary
-import im.vector.riotredesign.R
-import im.vector.riotredesign.core.extensions.addFragmentToBackstack
-import im.vector.riotredesign.core.platform.RiotFragment
-import kotlinx.android.synthetic.main.fragment_room_list.*
-import org.koin.android.ext.android.inject
-
-class RoomListFragment : RiotFragment(), RoomSummaryController.Callback {
-
- companion object {
-
- fun newInstance(): RoomListFragment {
- return RoomListFragment()
- }
-
- }
-
- private val matrix by inject()
- private val currentSession = matrix.currentSession!!
- private lateinit var roomController: RoomSummaryController
-
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
- return inflater.inflate(R.layout.fragment_room_list, container, false)
- }
-
- override fun onActivityCreated(savedInstanceState: Bundle?) {
- super.onActivityCreated(savedInstanceState)
- roomController = RoomSummaryController(this)
- epoxyRecyclerView.setController(roomController)
- currentSession.liveRoomSummaries().observe(this, Observer> { renderRooms(it) })
- }
-
- private fun renderRooms(rooms: List?) {
- roomController.setData(rooms)
- }
-
- override fun onRoomSelected(room: RoomSummary) {
- val detailFragment = RoomDetailFragment.newInstance(room.roomId)
- addFragmentToBackstack(detailFragment, R.id.homeFragmentContainer)
- }
-
-
-}
\ No newline at end of file
diff --git a/app/src/main/java/im/vector/riotredesign/features/home/RoomSummaryController.kt b/app/src/main/java/im/vector/riotredesign/features/home/RoomSummaryController.kt
deleted file mode 100644
index 0af1999bd3..0000000000
--- a/app/src/main/java/im/vector/riotredesign/features/home/RoomSummaryController.kt
+++ /dev/null
@@ -1,21 +0,0 @@
-package im.vector.riotredesign.features.home
-
-import com.airbnb.epoxy.TypedEpoxyController
-import im.vector.matrix.android.api.session.room.model.RoomSummary
-
-class RoomSummaryController(private val callback: Callback? = null
-) : TypedEpoxyController>() {
-
- override fun buildModels(data: List?) {
- data?.forEach {
- RoomItem(it.displayName, listener = { callback?.onRoomSelected(it) })
- .id(it.roomId)
- .addTo(this)
- }
- }
-
- interface Callback {
- fun onRoomSelected(room: RoomSummary)
- }
-
-}
\ No newline at end of file
diff --git a/app/src/main/java/im/vector/riotredesign/features/home/EventDiffUtilCallback.kt b/app/src/main/java/im/vector/riotredesign/features/home/detail/EventDiffUtilCallback.kt
similarity index 92%
rename from app/src/main/java/im/vector/riotredesign/features/home/EventDiffUtilCallback.kt
rename to app/src/main/java/im/vector/riotredesign/features/home/detail/EventDiffUtilCallback.kt
index 6ac1019259..e529dbbe0f 100644
--- a/app/src/main/java/im/vector/riotredesign/features/home/EventDiffUtilCallback.kt
+++ b/app/src/main/java/im/vector/riotredesign/features/home/detail/EventDiffUtilCallback.kt
@@ -1,4 +1,4 @@
-package im.vector.riotredesign.features.home
+package im.vector.riotredesign.features.home.detail
import android.support.v7.util.DiffUtil
import im.vector.matrix.android.api.session.events.model.EnrichedEvent
diff --git a/app/src/main/java/im/vector/riotredesign/features/home/detail/LoadingRoomDetailFragment.kt b/app/src/main/java/im/vector/riotredesign/features/home/detail/LoadingRoomDetailFragment.kt
new file mode 100644
index 0000000000..5d70ec54a5
--- /dev/null
+++ b/app/src/main/java/im/vector/riotredesign/features/home/detail/LoadingRoomDetailFragment.kt
@@ -0,0 +1,24 @@
+package im.vector.riotredesign.features.home.detail
+
+import android.os.Bundle
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import im.vector.riotredesign.R
+import im.vector.riotredesign.core.platform.RiotFragment
+
+class LoadingRoomDetailFragment : RiotFragment() {
+
+ companion object {
+
+ fun newInstance(): LoadingRoomDetailFragment {
+ return LoadingRoomDetailFragment()
+ }
+ }
+
+ override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
+ return inflater.inflate(R.layout.fragment_loading_room_detail, container, false)
+ }
+
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/im/vector/riotredesign/features/home/RoomDetailFragment.kt b/app/src/main/java/im/vector/riotredesign/features/home/detail/RoomDetailFragment.kt
similarity index 98%
rename from app/src/main/java/im/vector/riotredesign/features/home/RoomDetailFragment.kt
rename to app/src/main/java/im/vector/riotredesign/features/home/detail/RoomDetailFragment.kt
index 18ef510c5d..10dbcb38e8 100644
--- a/app/src/main/java/im/vector/riotredesign/features/home/RoomDetailFragment.kt
+++ b/app/src/main/java/im/vector/riotredesign/features/home/detail/RoomDetailFragment.kt
@@ -1,4 +1,4 @@
-package im.vector.riotredesign.features.home
+package im.vector.riotredesign.features.home.detail
import android.arch.lifecycle.Observer
import android.arch.paging.PagedList
diff --git a/app/src/main/java/im/vector/riotredesign/features/home/TimelineEventAdapter.kt b/app/src/main/java/im/vector/riotredesign/features/home/detail/TimelineEventAdapter.kt
similarity index 97%
rename from app/src/main/java/im/vector/riotredesign/features/home/TimelineEventAdapter.kt
rename to app/src/main/java/im/vector/riotredesign/features/home/detail/TimelineEventAdapter.kt
index ebf967cb63..fc35116b2d 100644
--- a/app/src/main/java/im/vector/riotredesign/features/home/TimelineEventAdapter.kt
+++ b/app/src/main/java/im/vector/riotredesign/features/home/detail/TimelineEventAdapter.kt
@@ -1,4 +1,4 @@
-package im.vector.riotredesign.features.home
+package im.vector.riotredesign.features.home.detail
import android.arch.paging.PagedList
import android.arch.paging.PagedListAdapter
diff --git a/app/src/main/java/im/vector/riotredesign/features/home/TimelineEventController.kt b/app/src/main/java/im/vector/riotredesign/features/home/detail/TimelineEventController.kt
similarity index 86%
rename from app/src/main/java/im/vector/riotredesign/features/home/TimelineEventController.kt
rename to app/src/main/java/im/vector/riotredesign/features/home/detail/TimelineEventController.kt
index e536d10136..cab815e167 100644
--- a/app/src/main/java/im/vector/riotredesign/features/home/TimelineEventController.kt
+++ b/app/src/main/java/im/vector/riotredesign/features/home/detail/TimelineEventController.kt
@@ -1,9 +1,10 @@
-package im.vector.riotredesign.features.home
+package im.vector.riotredesign.features.home.detail
import com.airbnb.epoxy.EpoxyAsyncUtil
import com.airbnb.epoxy.EpoxyModel
import com.airbnb.epoxy.paging.PagedListEpoxyController
import im.vector.matrix.android.api.session.events.model.Event
+import im.vector.riotredesign.features.home.LoadingItemModel_
class TimelineEventController : PagedListEpoxyController(
diffingHandler = EpoxyAsyncUtil.getAsyncBackgroundHandler()
diff --git a/app/src/main/java/im/vector/riotredesign/features/home/TimelineEventItem.kt b/app/src/main/java/im/vector/riotredesign/features/home/detail/TimelineEventItem.kt
similarity index 89%
rename from app/src/main/java/im/vector/riotredesign/features/home/TimelineEventItem.kt
rename to app/src/main/java/im/vector/riotredesign/features/home/detail/TimelineEventItem.kt
index 719a8c5dc3..31c2ebdeb9 100644
--- a/app/src/main/java/im/vector/riotredesign/features/home/TimelineEventItem.kt
+++ b/app/src/main/java/im/vector/riotredesign/features/home/detail/TimelineEventItem.kt
@@ -1,4 +1,4 @@
-package im.vector.riotredesign.features.home
+package im.vector.riotredesign.features.home.detail
import android.widget.TextView
import im.vector.riotredesign.R
diff --git a/app/src/main/java/im/vector/riotredesign/features/home/list/RoomListActions.kt b/app/src/main/java/im/vector/riotredesign/features/home/list/RoomListActions.kt
new file mode 100644
index 0000000000..e00f8f172c
--- /dev/null
+++ b/app/src/main/java/im/vector/riotredesign/features/home/list/RoomListActions.kt
@@ -0,0 +1,10 @@
+package im.vector.riotredesign.features.home.list
+
+import im.vector.matrix.android.api.session.room.model.RoomSummary
+
+sealed class RoomListActions {
+
+ data class SelectRoom(val roomSummary: RoomSummary) : RoomListActions()
+
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/im/vector/riotredesign/features/home/list/RoomListFragment.kt b/app/src/main/java/im/vector/riotredesign/features/home/list/RoomListFragment.kt
new file mode 100644
index 0000000000..103b7cdfaa
--- /dev/null
+++ b/app/src/main/java/im/vector/riotredesign/features/home/list/RoomListFragment.kt
@@ -0,0 +1,82 @@
+package im.vector.riotredesign.features.home.list
+
+import android.os.Bundle
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import com.airbnb.mvrx.*
+import im.vector.matrix.android.api.failure.Failure
+import im.vector.matrix.android.api.session.room.model.RoomSummary
+import im.vector.riotredesign.R
+import im.vector.riotredesign.core.platform.RiotFragment
+import im.vector.riotredesign.core.platform.StateView
+import im.vector.riotredesign.features.home.HomeNavigator
+import kotlinx.android.synthetic.main.fragment_room_list.*
+import org.koin.android.ext.android.inject
+
+class RoomListFragment : RiotFragment(), RoomSummaryController.Callback {
+
+ companion object {
+ fun newInstance(): RoomListFragment {
+ return RoomListFragment()
+ }
+ }
+
+ private val homeNavigator by inject()
+ private val viewModel: RoomListViewModel by fragmentViewModel()
+ private lateinit var roomController: RoomSummaryController
+
+ override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
+ return inflater.inflate(R.layout.fragment_room_list, container, false)
+ }
+
+ override fun onActivityCreated(savedInstanceState: Bundle?) {
+ super.onActivityCreated(savedInstanceState)
+ roomController = RoomSummaryController(this)
+ stateView.contentView = epoxyRecyclerView
+ epoxyRecyclerView.setController(roomController)
+ viewModel.subscribe { renderState(it) }
+ }
+
+ private fun renderState(state: RoomListViewState) {
+ when (state.roomSummaries) {
+ is Incomplete -> renderLoading()
+ is Success -> renderSuccess(state.roomSummaries(), state.selectedRoom)
+ is Fail -> renderFailure(state.roomSummaries.error)
+ }
+ if (state.showLastSelectedRoom && state.selectedRoom != null) {
+ homeNavigator.openRoomDetail(state.selectedRoom.roomId)
+ }
+ }
+
+ private fun renderSuccess(roomSummaries: List?, selectedRoom: RoomSummary?) {
+ if (roomSummaries.isNullOrEmpty()) {
+ stateView.state = StateView.State.Empty("Rejoignez une room pour commencer à utiliser l'application")
+ } else {
+ stateView.state = StateView.State.Content
+ }
+ roomController.setData(roomSummaries, selectedRoom)
+ }
+
+ private fun renderLoading() {
+ stateView.state = StateView.State.Loading
+ }
+
+ private fun renderFailure(error: Throwable) {
+ val message = when (error) {
+ is Failure.NetworkConnection -> "Pas de connexion internet"
+ else -> "Une erreur est survenue"
+ }
+ stateView.state = StateView.State.Error(message)
+ }
+
+ override fun onRoomSelected(room: RoomSummary) {
+ withState(viewModel) {
+ if (it.selectedRoom != room) {
+ viewModel.accept(RoomListActions.SelectRoom(room))
+ homeNavigator.openRoomDetail(room.roomId)
+ }
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/im/vector/riotredesign/features/home/list/RoomListViewModel.kt b/app/src/main/java/im/vector/riotredesign/features/home/list/RoomListViewModel.kt
new file mode 100644
index 0000000000..860f274681
--- /dev/null
+++ b/app/src/main/java/im/vector/riotredesign/features/home/list/RoomListViewModel.kt
@@ -0,0 +1,54 @@
+package im.vector.riotredesign.features.home.list
+
+import android.support.v4.app.FragmentActivity
+import com.airbnb.mvrx.BaseMvRxViewModel
+import com.airbnb.mvrx.MvRxViewModelFactory
+import im.vector.matrix.android.api.Matrix
+import im.vector.matrix.android.api.session.Session
+import im.vector.matrix.rx.rx
+import org.koin.android.ext.android.get
+
+class RoomListViewModel(initialState: RoomListViewState,
+ private val session: Session
+) : BaseMvRxViewModel(initialState) {
+
+ companion object : MvRxViewModelFactory {
+
+ @JvmStatic
+ override fun create(activity: FragmentActivity, state: RoomListViewState): RoomListViewModel {
+ val matrix = activity.get()
+ val currentSession = matrix.currentSession!!
+ return RoomListViewModel(state, currentSession)
+ }
+ }
+
+ init {
+ observeRoomSummaries()
+ }
+
+ fun accept(action: RoomListActions) {
+ when (action) {
+ is RoomListActions.SelectRoom -> handleSelectRoom(action)
+ }
+ }
+
+ // PRIVATE METHODS *****************************************************************************
+
+ private fun handleSelectRoom(action: RoomListActions.SelectRoom) {
+ session.saveLastSelectedRoom(action.roomSummary)
+ setState { copy(selectedRoom = action.roomSummary) }
+ }
+
+ private fun observeRoomSummaries() {
+ session
+ .rx().liveRoomSummaries()
+ .execute {
+ val selectedRoom = selectedRoom
+ ?: session.lastSelectedRoom()
+ ?: it.invoke()?.firstOrNull()
+
+ copy(roomSummaries = it, selectedRoom = selectedRoom)
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/im/vector/riotredesign/features/home/list/RoomListViewState.kt b/app/src/main/java/im/vector/riotredesign/features/home/list/RoomListViewState.kt
new file mode 100644
index 0000000000..30b16cff38
--- /dev/null
+++ b/app/src/main/java/im/vector/riotredesign/features/home/list/RoomListViewState.kt
@@ -0,0 +1,24 @@
+package im.vector.riotredesign.features.home.list
+
+import com.airbnb.mvrx.Async
+import com.airbnb.mvrx.MvRxState
+import com.airbnb.mvrx.Uninitialized
+import im.vector.matrix.android.api.session.room.model.RoomSummary
+
+data class RoomListViewState(
+ val roomSummaries: Async> = Uninitialized,
+ val selectedRoom: RoomSummary? = null
+) : MvRxState {
+
+ var showLastSelectedRoom: Boolean = true
+ private set
+ get() {
+ if (field) {
+ field = false
+ return true
+ }
+ return false
+ }
+
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/im/vector/riotredesign/features/home/list/RoomSummaryController.kt b/app/src/main/java/im/vector/riotredesign/features/home/list/RoomSummaryController.kt
new file mode 100644
index 0000000000..da2e3897db
--- /dev/null
+++ b/app/src/main/java/im/vector/riotredesign/features/home/list/RoomSummaryController.kt
@@ -0,0 +1,26 @@
+package im.vector.riotredesign.features.home.list
+
+import com.airbnb.epoxy.Typed2EpoxyController
+import im.vector.matrix.android.api.session.room.model.RoomSummary
+
+class RoomSummaryController(private val callback: Callback? = null
+
+) : Typed2EpoxyController, RoomSummary>() {
+
+ override fun buildModels(summaries: List?, selected: RoomSummary?) {
+ summaries?.forEach {
+ RoomSummaryItem(
+ it.displayName,
+ isSelected = it == selected,
+ listener = { callback?.onRoomSelected(it) }
+ )
+ .id(it.roomId)
+ .addTo(this)
+ }
+ }
+
+ interface Callback {
+ fun onRoomSelected(room: RoomSummary)
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/im/vector/riotredesign/features/home/RoomItem.kt b/app/src/main/java/im/vector/riotredesign/features/home/list/RoomSummaryItem.kt
similarity index 54%
rename from app/src/main/java/im/vector/riotredesign/features/home/RoomItem.kt
rename to app/src/main/java/im/vector/riotredesign/features/home/list/RoomSummaryItem.kt
index ea744bd57f..718628ddb0 100644
--- a/app/src/main/java/im/vector/riotredesign/features/home/RoomItem.kt
+++ b/app/src/main/java/im/vector/riotredesign/features/home/list/RoomSummaryItem.kt
@@ -1,17 +1,22 @@
-package im.vector.riotredesign.features.home
+package im.vector.riotredesign.features.home.list
+import android.support.v4.content.ContextCompat
import android.widget.TextView
import im.vector.riotredesign.R
import im.vector.riotredesign.core.epoxy.KotlinModel
+import im.vector.riotredesign.core.platform.CheckableConstraintLayout
-data class RoomItem(
+data class RoomSummaryItem(
val title: CharSequence,
+ val isSelected: Boolean,
val listener: (() -> Unit)? = null
) : KotlinModel(R.layout.item_room) {
val titleView by bind(R.id.titleView)
+ val rootView by bind(R.id.itemRoomLayout)
override fun bind() {
+ rootView.isChecked = isSelected
titleView.setOnClickListener { listener?.invoke() }
titleView.text = title
}
diff --git a/app/src/main/res/drawable/bg_room_item.xml b/app/src/main/res/drawable/bg_room_item.xml
new file mode 100644
index 0000000000..19bc072bbd
--- /dev/null
+++ b/app/src/main/res/drawable/bg_room_item.xml
@@ -0,0 +1,19 @@
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_home.xml b/app/src/main/res/layout/activity_home.xml
index 1238982278..0905e995c4 100644
--- a/app/src/main/res/layout/activity_home.xml
+++ b/app/src/main/res/layout/activity_home.xml
@@ -1,15 +1,21 @@
-
+ tools:openDrawer="start">
+
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_loading_room_detail.xml b/app/src/main/res/layout/fragment_loading_room_detail.xml
new file mode 100644
index 0000000000..d85e483bb2
--- /dev/null
+++ b/app/src/main/res/layout/fragment_loading_room_detail.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_room_list.xml b/app/src/main/res/layout/fragment_room_list.xml
index 8ac6b39f78..e2dd58a9d3 100644
--- a/app/src/main/res/layout/fragment_room_list.xml
+++ b/app/src/main/res/layout/fragment_room_list.xml
@@ -1,11 +1,13 @@
-
+ android:layout_height="match_parent"
+ android:background="@color/pale_grey">
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/item_room.xml b/app/src/main/res/layout/item_room.xml
index 4ab22892a8..2a59e5bb09 100644
--- a/app/src/main/res/layout/item_room.xml
+++ b/app/src/main/res/layout/item_room.xml
@@ -1,10 +1,28 @@
-
\ No newline at end of file
+ android:layout_height="wrap_content"
+ android:background="@drawable/bg_room_item"
+ android:minHeight="80dp">
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/view_state.xml b/app/src/main/res/layout/view_state.xml
new file mode 100644
index 0000000000..2441893b08
--- /dev/null
+++ b/app/src/main/res/layout/view_state.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index 3ab3e9cbce..9d1a958e68 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -3,4 +3,16 @@
#3F51B5
#303F9F
#FF4081
+
+
+ #f2f5f8
+ #2e3649
+ #7ac9a1
+ #212121
+ #007aff
+ #f56679
+ #a5a5a6
+ #5f6268
+ #7bb2ea
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 48b55d3ac8..6260b26bb2 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1,3 +1,6 @@
Riot Redesign
+
+ Réessayer
+
diff --git a/matrix-sdk-rx/.gitignore b/matrix-sdk-android-rx/.gitignore
similarity index 100%
rename from matrix-sdk-rx/.gitignore
rename to matrix-sdk-android-rx/.gitignore
diff --git a/matrix-sdk-android-rx/build.gradle b/matrix-sdk-android-rx/build.gradle
new file mode 100644
index 0000000000..0fdbb989d4
--- /dev/null
+++ b/matrix-sdk-android-rx/build.gradle
@@ -0,0 +1,40 @@
+apply plugin: 'com.android.library'
+apply plugin: 'kotlin-android'
+apply plugin: 'kotlin-kapt'
+
+android {
+ compileSdkVersion 28
+
+
+
+ defaultConfig {
+ minSdkVersion 16
+ targetSdkVersion 28
+ versionCode 1
+ versionName "1.0"
+
+ testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ implementation project(":matrix-sdk-android")
+ implementation 'com.android.support:appcompat-v7:28.0.0'
+ implementation 'io.reactivex.rxjava2:rxkotlin:2.3.0'
+ implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
+
+
+ testImplementation 'junit:junit:4.12'
+ androidTestImplementation 'com.android.support.test:runner:1.0.2'
+ androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
+}
diff --git a/matrix-sdk-android-rx/proguard-rules.pro b/matrix-sdk-android-rx/proguard-rules.pro
new file mode 100644
index 0000000000..f1b424510d
--- /dev/null
+++ b/matrix-sdk-android-rx/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
diff --git a/matrix-sdk-android-rx/src/androidTest/java/im/vector/matrix/rx/ExampleInstrumentedTest.java b/matrix-sdk-android-rx/src/androidTest/java/im/vector/matrix/rx/ExampleInstrumentedTest.java
new file mode 100644
index 0000000000..c404327464
--- /dev/null
+++ b/matrix-sdk-android-rx/src/androidTest/java/im/vector/matrix/rx/ExampleInstrumentedTest.java
@@ -0,0 +1,26 @@
+package im.vector.matrix.rx;
+
+import android.content.Context;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * @see Testing documentation
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+ @Test
+ public void useAppContext() {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getTargetContext();
+
+ assertEquals("im.vector.matrix.rx.test", appContext.getPackageName());
+ }
+}
diff --git a/matrix-sdk-android-rx/src/main/AndroidManifest.xml b/matrix-sdk-android-rx/src/main/AndroidManifest.xml
new file mode 100644
index 0000000000..b04927ec5a
--- /dev/null
+++ b/matrix-sdk-android-rx/src/main/AndroidManifest.xml
@@ -0,0 +1,2 @@
+
diff --git a/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/LiveDataObservable.kt b/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/LiveDataObservable.kt
new file mode 100644
index 0000000000..db180419e9
--- /dev/null
+++ b/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/LiveDataObservable.kt
@@ -0,0 +1,45 @@
+package im.vector.matrix.rx
+
+import android.arch.lifecycle.LiveData
+import android.arch.lifecycle.Observer
+import io.reactivex.Observable
+import io.reactivex.android.MainThreadDisposable
+
+private class LiveDataObservable(
+ private val liveData: LiveData,
+ private val valueIfNull: T? = null
+) : Observable() {
+
+ override fun subscribeActual(observer: io.reactivex.Observer) {
+ val relay = RemoveObserverInMainThread(observer)
+ observer.onSubscribe(relay)
+ liveData.observeForever(relay)
+ }
+
+ private inner class RemoveObserverInMainThread(private val observer: io.reactivex.Observer)
+ : MainThreadDisposable(), Observer {
+
+ override fun onChanged(t: T?) {
+ if (!isDisposed) {
+ if (t == null) {
+ if (valueIfNull != null) {
+ observer.onNext(valueIfNull)
+ } else {
+ observer.onError(NullPointerException(
+ "convert liveData value t to RxJava onNext(t), t cannot be null"))
+ }
+ } else {
+ observer.onNext(t)
+ }
+ }
+ }
+
+ override fun onDispose() {
+ liveData.removeObserver(this)
+ }
+ }
+}
+
+fun LiveData.asObservable(): Observable {
+ return LiveDataObservable(this)
+}
\ No newline at end of file
diff --git a/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxSession.kt b/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxSession.kt
new file mode 100644
index 0000000000..0361860cef
--- /dev/null
+++ b/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxSession.kt
@@ -0,0 +1,17 @@
+package im.vector.matrix.rx
+
+import im.vector.matrix.android.api.session.Session
+import im.vector.matrix.android.api.session.room.model.RoomSummary
+import io.reactivex.Observable
+
+class RxSession(private val session: Session) {
+
+ fun liveRoomSummaries(): Observable> {
+ return session.liveRoomSummaries().asObservable()
+ }
+
+}
+
+fun Session.rx(): RxSession {
+ return RxSession(this)
+}
\ No newline at end of file
diff --git a/matrix-sdk-android-rx/src/main/res/values/strings.xml b/matrix-sdk-android-rx/src/main/res/values/strings.xml
new file mode 100644
index 0000000000..bf89f17101
--- /dev/null
+++ b/matrix-sdk-android-rx/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
+
+ matrix-sdk-android-rx
+
diff --git a/matrix-sdk-android-rx/src/test/java/im/vector/matrix/rx/ExampleUnitTest.java b/matrix-sdk-android-rx/src/test/java/im/vector/matrix/rx/ExampleUnitTest.java
new file mode 100644
index 0000000000..7af41c88e1
--- /dev/null
+++ b/matrix-sdk-android-rx/src/test/java/im/vector/matrix/rx/ExampleUnitTest.java
@@ -0,0 +1,17 @@
+package im.vector.matrix.rx;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see Testing documentation
+ */
+public class ExampleUnitTest {
+ @Test
+ public void addition_isCorrect() {
+ assertEquals(4, 2 + 2);
+ }
+}
\ No newline at end of file
diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/failure/Failure.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/failure/Failure.kt
index 7a6e0d4c28..31f9ef5baf 100644
--- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/failure/Failure.kt
+++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/failure/Failure.kt
@@ -2,22 +2,12 @@ package im.vector.matrix.android.api.failure
import java.io.IOException
-sealed class Failure {
+sealed class Failure(cause: Throwable? = null) : Throwable(cause = cause) {
- data class Unknown(val exception: Exception? = null) : Failure()
- data class NetworkConnection(val ioException: IOException) : Failure()
- data class ServerError(val error: MatrixError) : Failure()
+ data class Unknown(val throwable: Throwable? = null) : Failure(throwable)
+ data class NetworkConnection(val ioException: IOException) : Failure(ioException)
+ data class ServerError(val error: MatrixError) : Failure(RuntimeException(error.toString()))
abstract class FeatureFailure : Failure()
- fun toException(): Exception {
- return when (this) {
- is Unknown -> this.exception ?: RuntimeException("Unknown error")
- is NetworkConnection -> this.ioException
- is ServerError -> RuntimeException(this.error.toString())
- is FeatureFailure -> RuntimeException("Feature error")
- }
-
- }
-
}
\ No newline at end of file
diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/RoomService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/RoomService.kt
index 8c722447a0..79170bdbd8 100644
--- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/RoomService.kt
+++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/RoomService.kt
@@ -13,5 +13,9 @@ interface RoomService {
fun liveRoomSummaries(): LiveData>
+ fun lastSelectedRoom(): RoomSummary?
+
+ fun saveLastSelectedRoom(roomSummary: RoomSummary)
+
}
\ No newline at end of file
diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/mapper/RoomSummaryMapper.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/mapper/RoomSummaryMapper.kt
index 31fdca0361..380744a007 100644
--- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/mapper/RoomSummaryMapper.kt
+++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/mapper/RoomSummaryMapper.kt
@@ -13,8 +13,20 @@ object RoomSummaryMapper {
roomSummaryEntity.topic ?: ""
)
}
+
+ internal fun map(roomSummary: RoomSummary): RoomSummaryEntity {
+ return RoomSummaryEntity(
+ roomSummary.roomId,
+ roomSummary.displayName,
+ roomSummary.topic
+ )
+ }
}
fun RoomSummaryEntity.asDomain(): RoomSummary {
return RoomSummaryMapper.map(this)
+}
+
+fun RoomSummaryEntity.asEntity(): RoomSummary {
+ return RoomSummaryMapper.map(this)
}
\ No newline at end of file
diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/model/RoomSummaryEntity.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/model/RoomSummaryEntity.kt
index 1822e310ad..53a95c0cf2 100644
--- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/model/RoomSummaryEntity.kt
+++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/model/RoomSummaryEntity.kt
@@ -11,7 +11,8 @@ open class RoomSummaryEntity(@PrimaryKey var roomId: String = "",
var lastMessage: EventEntity? = null,
var heroes: RealmList = RealmList(),
var joinedMembersCount: Int? = 0,
- var invitedMembersCount: Int? = 0
+ var invitedMembersCount: Int? = 0,
+ var isLatestSelected: Boolean = false
) : RealmObject() {
companion object
diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/query/RoomSummaryEntityQueries.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/query/RoomSummaryEntityQueries.kt
index 3632ae4cc3..8d2fada708 100644
--- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/query/RoomSummaryEntityQueries.kt
+++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/query/RoomSummaryEntityQueries.kt
@@ -13,3 +13,9 @@ fun RoomSummaryEntity.Companion.where(realm: Realm, roomId: String? = null): Rea
}
return query
}
+
+fun RoomSummaryEntity.Companion.lastSelected(realm: Realm): RoomSummaryEntity? {
+ return realm.where()
+ .equalTo(RoomSummaryEntityFields.IS_LATEST_SELECTED, true)
+ .findFirst()
+}
diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/DefaultSession.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/DefaultSession.kt
index 3cc29b6d5c..af9bf57f00 100644
--- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/DefaultSession.kt
+++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/DefaultSession.kt
@@ -75,6 +75,14 @@ class DefaultSession(override val sessionParams: SessionParams) : Session, KoinC
return roomService.liveRoomSummaries()
}
+ override fun lastSelectedRoom(): RoomSummary? {
+ return roomService.lastSelectedRoom()
+ }
+
+ override fun saveLastSelectedRoom(roomSummary: RoomSummary) {
+ roomService.saveLastSelectedRoom(roomSummary)
+ }
+
// Private methods *****************************************************************************
private fun checkIsMainThread() {
diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/DefaultRoomService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/DefaultRoomService.kt
index cf0dc43624..39e30a5f39 100644
--- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/DefaultRoomService.kt
+++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/DefaultRoomService.kt
@@ -8,6 +8,7 @@ import im.vector.matrix.android.api.session.room.model.RoomSummary
import im.vector.matrix.android.internal.database.mapper.asDomain
import im.vector.matrix.android.internal.database.model.RoomEntity
import im.vector.matrix.android.internal.database.model.RoomSummaryEntity
+import im.vector.matrix.android.internal.database.query.lastSelected
import im.vector.matrix.android.internal.database.query.where
class DefaultRoomService(private val monarchy: Monarchy) : RoomService {
@@ -42,5 +43,20 @@ class DefaultRoomService(private val monarchy: Monarchy) : RoomService {
)
}
+ override fun lastSelectedRoom(): RoomSummary? {
+ var lastSelected: RoomSummary? = null
+ monarchy.doWithRealm { realm ->
+ lastSelected = RoomSummaryEntity.lastSelected(realm)?.asDomain()
+ }
+ return lastSelected
+ }
+ override fun saveLastSelectedRoom(roomSummary: RoomSummary) {
+ monarchy.writeAsync { realm ->
+ val lastSelected = RoomSummaryEntity.lastSelected(realm)
+ val roomSummaryEntity = RoomSummaryEntity.where(realm, roomSummary.roomId).findFirst()
+ lastSelected?.isLatestSelected = false
+ roomSummaryEntity?.isLatestSelected = true
+ }
+ }
}
\ No newline at end of file
diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/TimelineBoundaryCallback.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/TimelineBoundaryCallback.kt
index 63d3f1ffeb..7a17527158 100644
--- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/TimelineBoundaryCallback.kt
+++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/TimelineBoundaryCallback.kt
@@ -53,7 +53,7 @@ class TimelineBoundaryCallback(private val roomId: String,
}
override fun onFailure(failure: Failure) {
- pagingRequestCallback.recordFailure(failure.toException())
+ pagingRequestCallback.recordFailure(failure)
}
}
}
diff --git a/matrix-sdk-rx/build.gradle b/matrix-sdk-rx/build.gradle
deleted file mode 100644
index baa942e8fb..0000000000
--- a/matrix-sdk-rx/build.gradle
+++ /dev/null
@@ -1,8 +0,0 @@
-apply plugin: 'java-library'
-apply plugin: "kotlin"
-
-dependencies {
- implementation fileTree(dir: 'libs', include: ['*.jar'])
- implementation 'io.reactivex.rxjava2:rxkotlin:2.3.0'
-
-}
diff --git a/matrix-sdk-rx/src/main/java/im/vector/matrix/rx/MatrixRx.kt b/matrix-sdk-rx/src/main/java/im/vector/matrix/rx/MatrixRx.kt
deleted file mode 100644
index 5f5148aa28..0000000000
--- a/matrix-sdk-rx/src/main/java/im/vector/matrix/rx/MatrixRx.kt
+++ /dev/null
@@ -1,3 +0,0 @@
-package im.vector.matrix.rx
-
-class MatrixRx
diff --git a/settings.gradle b/settings.gradle
index cb22bfd794..97da6de7d4 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1 @@
-include ':app', ':matrix-sdk-rx', ':matrix-sdk-android'
+include ':app', ':matrix-sdk-android', ':matrix-sdk-android-rx'