Import and adapt Terms Of Service management: SDK and UI (compiling) - still fixing issue

This commit is contained in:
Benoit Marty 2020-05-07 21:09:03 +02:00
parent e86460b578
commit 426171508e
2 changed files with 15 additions and 15 deletions

View File

@ -20,7 +20,6 @@ import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AlertDialog
import androidx.lifecycle.Observer
import com.airbnb.mvrx.fragmentViewModel
import com.airbnb.mvrx.withState
import im.vector.matrix.android.api.session.identity.ThreePid
@ -29,6 +28,7 @@ import im.vector.riotx.R
import im.vector.riotx.core.extensions.cleanup
import im.vector.riotx.core.extensions.configureWith
import im.vector.riotx.core.extensions.exhaustive
import im.vector.riotx.core.extensions.observeEvent
import im.vector.riotx.core.platform.VectorBaseActivity
import im.vector.riotx.core.platform.VectorBaseFragment
import im.vector.riotx.features.discovery.change.SetIdentityServerFragment
@ -56,11 +56,12 @@ class DiscoverySettingsFragment @Inject constructor(
controller.listener = this
recyclerView.configureWith(controller)
sharedViewModel.navigateEvent.observe(viewLifecycleOwner, Observer {
if (it.peekContent().first == DiscoverySharedViewModel.NEW_IDENTITY_SERVER_SET_REQUEST) {
viewModel.handle(DiscoverySettingsAction.ChangeIdentityServer(it.peekContent().second))
}
})
sharedViewModel.navigateEvent.observeEvent(this) {
when (it) {
is DiscoverySharedViewModelAction.ChangeIdentityServer ->
viewModel.handle(DiscoverySettingsAction.ChangeIdentityServer(it.newUrl))
}.exhaustive
}
viewModel.observeViewEvents {
when (it) {

View File

@ -17,19 +17,18 @@ package im.vector.riotx.features.discovery
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import im.vector.riotx.core.extensions.postLiveEvent
import im.vector.riotx.core.utils.LiveEvent
import javax.inject.Inject
// TODO Rework this
sealed class DiscoverySharedViewModelAction {
data class ChangeIdentityServer(val newUrl: String) : DiscoverySharedViewModelAction()
}
class DiscoverySharedViewModel @Inject constructor() : ViewModel() {
var navigateEvent = MutableLiveData<LiveEvent<DiscoverySharedViewModelAction>>()
var navigateEvent = MutableLiveData<LiveEvent<Pair<String, String>>>()
companion object {
const val NEW_IDENTITY_SERVER_SET_REQUEST = "NEW_IDENTITY_SERVER_SET_REQUEST"
}
fun requestChangeToIdentityServer(server: String) {
navigateEvent.postValue(LiveEvent(NEW_IDENTITY_SERVER_SET_REQUEST to server))
fun requestChangeToIdentityServer(serverUrl: String) {
navigateEvent.postLiveEvent(DiscoverySharedViewModelAction.ChangeIdentityServer(serverUrl))
}
}