forked from GitHub-Mirror/riotX-android
Ganfra's review: use observeEvent
This commit is contained in:
parent
b437837809
commit
c0be04f46c
@ -17,11 +17,11 @@
|
|||||||
package im.vector.riotredesign.features.roomdirectory
|
package im.vector.riotredesign.features.roomdirectory
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.lifecycle.Observer
|
|
||||||
import com.airbnb.mvrx.viewModel
|
import com.airbnb.mvrx.viewModel
|
||||||
import im.vector.riotredesign.R
|
import im.vector.riotredesign.R
|
||||||
import im.vector.riotredesign.core.extensions.addFragment
|
import im.vector.riotredesign.core.extensions.addFragment
|
||||||
import im.vector.riotredesign.core.extensions.addFragmentToBackstack
|
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.core.platform.VectorBaseActivity
|
||||||
import im.vector.riotredesign.features.roomdirectory.createroom.CreateRoomFragment
|
import im.vector.riotredesign.features.roomdirectory.createroom.CreateRoomFragment
|
||||||
import im.vector.riotredesign.features.roomdirectory.picker.RoomDirectoryPickerFragment
|
import im.vector.riotredesign.features.roomdirectory.picker.RoomDirectoryPickerFragment
|
||||||
@ -48,14 +48,14 @@ class RoomDirectoryActivity : VectorBaseActivity() {
|
|||||||
|
|
||||||
bindScope(getOrCreateScope(RoomDirectoryModule.ROOM_DIRECTORY_SCOPE))
|
bindScope(getOrCreateScope(RoomDirectoryModule.ROOM_DIRECTORY_SCOPE))
|
||||||
|
|
||||||
navigationViewModel.navigateTo.observe(this, Observer { liveEvent ->
|
navigationViewModel.navigateTo.observeEvent(this) { navigation ->
|
||||||
when (liveEvent.getContentIfNotHandled() ?: return@Observer) {
|
when (navigation) {
|
||||||
is Navigation.Back -> onBackPressed()
|
is Navigation.Back -> onBackPressed()
|
||||||
is Navigation.CreateRoom -> addFragmentToBackstack(CreateRoomFragment(), R.id.simpleFragmentContainer)
|
is Navigation.CreateRoom -> addFragmentToBackstack(CreateRoomFragment(), R.id.simpleFragmentContainer)
|
||||||
is Navigation.ChangeProtocol -> addFragmentToBackstack(RoomDirectoryPickerFragment(), R.id.simpleFragmentContainer)
|
is Navigation.ChangeProtocol -> addFragmentToBackstack(RoomDirectoryPickerFragment(), R.id.simpleFragmentContainer)
|
||||||
is Navigation.Close -> finish()
|
is Navigation.Close -> finish()
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initUiAndData() {
|
override fun initUiAndData() {
|
||||||
|
Loading…
Reference in New Issue
Block a user