From c0be04f46c81c307d2140e588728dd9d0c8c6e09 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 10 Jun 2019 16:39:46 +0200 Subject: [PATCH] Ganfra's review: use observeEvent --- .../features/roomdirectory/RoomDirectoryActivity.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vector/src/main/java/im/vector/riotredesign/features/roomdirectory/RoomDirectoryActivity.kt b/vector/src/main/java/im/vector/riotredesign/features/roomdirectory/RoomDirectoryActivity.kt index 083f1d882b..87b136a670 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/roomdirectory/RoomDirectoryActivity.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/roomdirectory/RoomDirectoryActivity.kt @@ -17,11 +17,11 @@ package im.vector.riotredesign.features.roomdirectory import android.os.Bundle -import androidx.lifecycle.Observer import com.airbnb.mvrx.viewModel import im.vector.riotredesign.R import im.vector.riotredesign.core.extensions.addFragment import im.vector.riotredesign.core.extensions.addFragmentToBackstack +import im.vector.riotredesign.core.extensions.observeEvent import im.vector.riotredesign.core.platform.VectorBaseActivity import im.vector.riotredesign.features.roomdirectory.createroom.CreateRoomFragment import im.vector.riotredesign.features.roomdirectory.picker.RoomDirectoryPickerFragment @@ -48,14 +48,14 @@ class RoomDirectoryActivity : VectorBaseActivity() { bindScope(getOrCreateScope(RoomDirectoryModule.ROOM_DIRECTORY_SCOPE)) - navigationViewModel.navigateTo.observe(this, Observer { liveEvent -> - when (liveEvent.getContentIfNotHandled() ?: return@Observer) { + navigationViewModel.navigateTo.observeEvent(this) { navigation -> + when (navigation) { is Navigation.Back -> onBackPressed() is Navigation.CreateRoom -> addFragmentToBackstack(CreateRoomFragment(), R.id.simpleFragmentContainer) is Navigation.ChangeProtocol -> addFragmentToBackstack(RoomDirectoryPickerFragment(), R.id.simpleFragmentContainer) is Navigation.Close -> finish() } - }) + } } override fun initUiAndData() {