Move class to dedicated file

This commit is contained in:
Benoit Marty 2019-11-08 12:01:36 +01:00
parent fa5d44af65
commit c8bc553caa
18 changed files with 100 additions and 43 deletions

View file

@ -18,4 +18,4 @@ package im.vector.riotx.features.home
import im.vector.riotx.core.platform.VectorActionViewModel import im.vector.riotx.core.platform.VectorActionViewModel
class HomeActionViewModel : VectorActionViewModel<HomeActivity.HomeActivityAction>() class HomeActionViewModel : VectorActionViewModel<HomeActivityAction>()

View file

@ -33,7 +33,6 @@ import im.vector.riotx.core.di.ScreenComponent
import im.vector.riotx.core.extensions.hideKeyboard import im.vector.riotx.core.extensions.hideKeyboard
import im.vector.riotx.core.extensions.replaceFragment import im.vector.riotx.core.extensions.replaceFragment
import im.vector.riotx.core.platform.ToolbarConfigurable import im.vector.riotx.core.platform.ToolbarConfigurable
import im.vector.riotx.core.platform.VectorAction
import im.vector.riotx.core.platform.VectorBaseActivity import im.vector.riotx.core.platform.VectorBaseActivity
import im.vector.riotx.core.pushers.PushersManager import im.vector.riotx.core.pushers.PushersManager
import im.vector.riotx.features.disclaimer.showDisclaimerDialog import im.vector.riotx.features.disclaimer.showDisclaimerDialog
@ -48,12 +47,6 @@ import javax.inject.Inject
class HomeActivity : VectorBaseActivity(), ToolbarConfigurable { class HomeActivity : VectorBaseActivity(), ToolbarConfigurable {
// Supported navigation actions for this Activity
sealed class HomeActivityAction : VectorAction {
object OpenDrawer : HomeActivityAction()
object OpenGroup : HomeActivityAction()
}
private lateinit var actionViewModel: HomeActionViewModel private lateinit var actionViewModel: HomeActionViewModel
@Inject lateinit var activeSessionHolder: ActiveSessionHolder @Inject lateinit var activeSessionHolder: ActiveSessionHolder

View file

@ -0,0 +1,27 @@
/*
* Copyright 2019 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package im.vector.riotx.features.home
import im.vector.riotx.core.platform.VectorAction
/**
* Supported navigation actions for [HomeActivity]
*/
sealed class HomeActivityAction : VectorAction {
object OpenDrawer : HomeActivityAction()
object OpenGroup : HomeActivityAction()
}

View file

@ -129,7 +129,7 @@ class HomeDetailFragment @Inject constructor(
} }
groupToolbar.title = "" groupToolbar.title = ""
groupToolbarAvatarImageView.setOnClickListener { groupToolbarAvatarImageView.setOnClickListener {
actionViewModel.post(HomeActivity.HomeActivityAction.OpenDrawer) actionViewModel.post(HomeActivityAction.OpenDrawer)
} }
} }

View file

@ -0,0 +1,25 @@
/*
* Copyright 2019 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package im.vector.riotx.features.home.createdirect
import im.vector.riotx.core.platform.VectorAction
sealed class CreateDirectRoomAction : VectorAction {
object OpenUsersDirectory : CreateDirectRoomAction()
object Close : CreateDirectRoomAction()
object GoBack : CreateDirectRoomAction()
}

View file

@ -18,4 +18,4 @@ package im.vector.riotx.features.home.createdirect
import im.vector.riotx.core.platform.VectorActionViewModel import im.vector.riotx.core.platform.VectorActionViewModel
class CreateDirectRoomActionViewModel : VectorActionViewModel<CreateDirectRoomActivity.CreateDirectRoomAction>() class CreateDirectRoomActionViewModel : VectorActionViewModel<CreateDirectRoomAction>()

View file

@ -19,7 +19,6 @@ package im.vector.riotx.features.home.createdirect
import im.vector.matrix.android.api.session.user.model.User import im.vector.matrix.android.api.session.user.model.User
sealed class CreateDirectRoomActions { sealed class CreateDirectRoomActions {
object CreateRoomAndInviteSelectedUsers : CreateDirectRoomActions() object CreateRoomAndInviteSelectedUsers : CreateDirectRoomActions()
data class FilterKnownUsers(val value: String) : CreateDirectRoomActions() data class FilterKnownUsers(val value: String) : CreateDirectRoomActions()
data class SearchDirectoryUsers(val value: String) : CreateDirectRoomActions() data class SearchDirectoryUsers(val value: String) : CreateDirectRoomActions()

View file

@ -32,19 +32,12 @@ import im.vector.riotx.core.error.ErrorFormatter
import im.vector.riotx.core.extensions.addFragment import im.vector.riotx.core.extensions.addFragment
import im.vector.riotx.core.extensions.addFragmentToBackstack import im.vector.riotx.core.extensions.addFragmentToBackstack
import im.vector.riotx.core.platform.SimpleFragmentActivity import im.vector.riotx.core.platform.SimpleFragmentActivity
import im.vector.riotx.core.platform.VectorAction
import im.vector.riotx.core.platform.WaitingViewData import im.vector.riotx.core.platform.WaitingViewData
import kotlinx.android.synthetic.main.activity.* import kotlinx.android.synthetic.main.activity.*
import javax.inject.Inject import javax.inject.Inject
class CreateDirectRoomActivity : SimpleFragmentActivity() { class CreateDirectRoomActivity : SimpleFragmentActivity() {
sealed class CreateDirectRoomAction : VectorAction {
object OpenUsersDirectory : CreateDirectRoomAction()
object Close : CreateDirectRoomAction()
object GoBack : CreateDirectRoomAction()
}
private val viewModel: CreateDirectRoomViewModel by viewModel() private val viewModel: CreateDirectRoomViewModel by viewModel()
private lateinit var actionViewModel: CreateDirectRoomActionViewModel private lateinit var actionViewModel: CreateDirectRoomActionViewModel
@Inject lateinit var createDirectRoomViewModelFactory: CreateDirectRoomViewModel.Factory @Inject lateinit var createDirectRoomViewModelFactory: CreateDirectRoomViewModel.Factory

View file

@ -70,7 +70,7 @@ class CreateDirectRoomDirectoryUsersFragment @Inject constructor(
private fun setupCloseView() { private fun setupCloseView() {
createDirectRoomClose.setOnClickListener { createDirectRoomClose.setOnClickListener {
actionViewModel.post(CreateDirectRoomActivity.CreateDirectRoomAction.GoBack) actionViewModel.post(CreateDirectRoomAction.GoBack)
} }
} }
@ -81,7 +81,7 @@ class CreateDirectRoomDirectoryUsersFragment @Inject constructor(
override fun onItemClick(user: User) { override fun onItemClick(user: User) {
view?.hideKeyboard() view?.hideKeyboard()
viewModel.handle(CreateDirectRoomActions.SelectUser(user)) viewModel.handle(CreateDirectRoomActions.SelectUser(user))
actionViewModel.post(CreateDirectRoomActivity.CreateDirectRoomAction.GoBack) actionViewModel.post(CreateDirectRoomAction.GoBack)
} }
override fun retryDirectoryUsersRequest() { override fun retryDirectoryUsersRequest() {

View file

@ -89,7 +89,7 @@ class CreateDirectRoomKnownUsersFragment @Inject constructor(
private fun setupAddByMatrixIdView() { private fun setupAddByMatrixIdView() {
addByMatrixId.setOnClickListener { addByMatrixId.setOnClickListener {
actionViewModel.post(CreateDirectRoomActivity.CreateDirectRoomAction.OpenUsersDirectory) actionViewModel.post(CreateDirectRoomAction.OpenUsersDirectory)
} }
} }

View file

@ -27,7 +27,7 @@ import im.vector.riotx.core.extensions.observeEvent
import im.vector.riotx.core.platform.StateView import im.vector.riotx.core.platform.StateView
import im.vector.riotx.core.platform.VectorBaseFragment import im.vector.riotx.core.platform.VectorBaseFragment
import im.vector.riotx.features.home.HomeActionViewModel import im.vector.riotx.features.home.HomeActionViewModel
import im.vector.riotx.features.home.HomeActivity import im.vector.riotx.features.home.HomeActivityAction
import kotlinx.android.synthetic.main.fragment_group_list.* import kotlinx.android.synthetic.main.fragment_group_list.*
import javax.inject.Inject import javax.inject.Inject
@ -49,7 +49,7 @@ class GroupListFragment @Inject constructor(
groupListEpoxyRecyclerView.setController(groupController) groupListEpoxyRecyclerView.setController(groupController)
viewModel.subscribe { renderState(it) } viewModel.subscribe { renderState(it) }
viewModel.openGroupLiveData.observeEvent(this) { viewModel.openGroupLiveData.observeEvent(this) {
actionViewModel.post(HomeActivity.HomeActivityAction.OpenGroup) actionViewModel.post(HomeActivityAction.OpenGroup)
} }
} }

View file

@ -71,7 +71,7 @@ class PublicRoomsFragment @Inject constructor(
.disposeOnDestroy() .disposeOnDestroy()
publicRoomsCreateNewRoom.setOnClickListener { publicRoomsCreateNewRoom.setOnClickListener {
actionViewModel.post(RoomDirectoryActivity.RoomDirectoryAction.CreateRoom) actionViewModel.post(RoomDirectoryAction.CreateRoom)
} }
viewModel.joinRoomErrorLiveData.observeEvent(this) { throwable -> viewModel.joinRoomErrorLiveData.observeEvent(this) { throwable ->
@ -83,7 +83,7 @@ class PublicRoomsFragment @Inject constructor(
override fun onOptionsItemSelected(item: MenuItem): Boolean { override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) { return when (item.itemId) {
R.id.menu_room_directory_change_protocol -> { R.id.menu_room_directory_change_protocol -> {
actionViewModel.post(RoomDirectoryActivity.RoomDirectoryAction.ChangeProtocol) actionViewModel.post(RoomDirectoryAction.ChangeProtocol)
true true
} }
else -> else ->

View file

@ -0,0 +1,29 @@
/*
* Copyright 2019 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package im.vector.riotx.features.roomdirectory
import im.vector.riotx.core.platform.VectorAction
/**
* Supported navigation actions for [RoomDirectoryActivity]
*/
sealed class RoomDirectoryAction : VectorAction {
object Back : RoomDirectoryAction()
object CreateRoom : RoomDirectoryAction()
object Close : RoomDirectoryAction()
object ChangeProtocol : RoomDirectoryAction()
}

View file

@ -18,4 +18,4 @@ package im.vector.riotx.features.roomdirectory
import im.vector.riotx.core.platform.VectorActionViewModel import im.vector.riotx.core.platform.VectorActionViewModel
class RoomDirectoryActionViewModel : VectorActionViewModel<RoomDirectoryActivity.RoomDirectoryAction>() class RoomDirectoryActionViewModel : VectorActionViewModel<RoomDirectoryAction>()

View file

@ -25,7 +25,6 @@ import im.vector.riotx.R
import im.vector.riotx.core.di.ScreenComponent import im.vector.riotx.core.di.ScreenComponent
import im.vector.riotx.core.extensions.addFragment import im.vector.riotx.core.extensions.addFragment
import im.vector.riotx.core.extensions.addFragmentToBackstack import im.vector.riotx.core.extensions.addFragmentToBackstack
import im.vector.riotx.core.platform.VectorAction
import im.vector.riotx.core.platform.VectorBaseActivity import im.vector.riotx.core.platform.VectorBaseActivity
import im.vector.riotx.features.roomdirectory.createroom.CreateRoomFragment import im.vector.riotx.features.roomdirectory.createroom.CreateRoomFragment
import im.vector.riotx.features.roomdirectory.createroom.CreateRoomViewModel import im.vector.riotx.features.roomdirectory.createroom.CreateRoomViewModel
@ -34,14 +33,6 @@ import javax.inject.Inject
class RoomDirectoryActivity : VectorBaseActivity() { class RoomDirectoryActivity : VectorBaseActivity() {
// Supported navigation actions for this Activity
sealed class RoomDirectoryAction : VectorAction {
object Back : RoomDirectoryAction()
object CreateRoom : RoomDirectoryAction()
object Close : RoomDirectoryAction()
object ChangeProtocol : RoomDirectoryAction()
}
@Inject lateinit var createRoomViewModelFactory: CreateRoomViewModel.Factory @Inject lateinit var createRoomViewModelFactory: CreateRoomViewModel.Factory
@Inject lateinit var roomDirectoryViewModelFactory: RoomDirectoryViewModel.Factory @Inject lateinit var roomDirectoryViewModelFactory: RoomDirectoryViewModel.Factory
private val roomDirectoryViewModel: RoomDirectoryViewModel by viewModel() private val roomDirectoryViewModel: RoomDirectoryViewModel by viewModel()

View file

@ -26,7 +26,7 @@ import im.vector.riotx.R
import im.vector.riotx.core.extensions.addFragment import im.vector.riotx.core.extensions.addFragment
import im.vector.riotx.core.platform.ToolbarConfigurable import im.vector.riotx.core.platform.ToolbarConfigurable
import im.vector.riotx.core.platform.VectorBaseActivity import im.vector.riotx.core.platform.VectorBaseActivity
import im.vector.riotx.features.roomdirectory.RoomDirectoryActivity import im.vector.riotx.features.roomdirectory.RoomDirectoryAction
import im.vector.riotx.features.roomdirectory.RoomDirectoryActionViewModel import im.vector.riotx.features.roomdirectory.RoomDirectoryActionViewModel
import javax.inject.Inject import javax.inject.Inject
@ -59,8 +59,8 @@ class CreateRoomActivity : VectorBaseActivity(), ToolbarConfigurable {
actionViewModel.observe() actionViewModel.observe()
.subscribe { navigation -> .subscribe { navigation ->
when (navigation) { when (navigation) {
is RoomDirectoryActivity.RoomDirectoryAction.Back, is RoomDirectoryAction.Back,
is RoomDirectoryActivity.RoomDirectoryAction.Close -> finish() is RoomDirectoryAction.Close -> finish()
} }
} }
.disposeOnDestroy() .disposeOnDestroy()

View file

@ -25,7 +25,7 @@ import com.airbnb.mvrx.activityViewModel
import com.airbnb.mvrx.withState import com.airbnb.mvrx.withState
import im.vector.riotx.R import im.vector.riotx.R
import im.vector.riotx.core.platform.VectorBaseFragment import im.vector.riotx.core.platform.VectorBaseFragment
import im.vector.riotx.features.roomdirectory.RoomDirectoryActivity import im.vector.riotx.features.roomdirectory.RoomDirectoryAction
import im.vector.riotx.features.roomdirectory.RoomDirectoryActionViewModel import im.vector.riotx.features.roomdirectory.RoomDirectoryActionViewModel
import kotlinx.android.synthetic.main.fragment_create_room.* import kotlinx.android.synthetic.main.fragment_create_room.*
import timber.log.Timber import timber.log.Timber
@ -46,7 +46,7 @@ class CreateRoomFragment @Inject constructor(private val createRoomController: C
actionViewModel = ViewModelProviders.of(requireActivity()).get(RoomDirectoryActionViewModel::class.java) actionViewModel = ViewModelProviders.of(requireActivity()).get(RoomDirectoryActionViewModel::class.java)
setupRecyclerView() setupRecyclerView()
createRoomClose.setOnClickListener { createRoomClose.setOnClickListener {
actionViewModel.post(RoomDirectoryActivity.RoomDirectoryAction.Back) actionViewModel.post(RoomDirectoryAction.Back)
} }
} }
@ -93,7 +93,7 @@ class CreateRoomFragment @Inject constructor(private val createRoomController: C
// Navigate to freshly created room // Navigate to freshly created room
navigator.openRoom(requireActivity(), async()) navigator.openRoom(requireActivity(), async())
actionViewModel.post(RoomDirectoryActivity.RoomDirectoryAction.Close) actionViewModel.post(RoomDirectoryAction.Close)
} else { } else {
// Populate list with Epoxy // Populate list with Epoxy
createRoomController.setData(state) createRoomController.setData(state)

View file

@ -27,8 +27,8 @@ import com.airbnb.mvrx.withState
import im.vector.matrix.android.api.session.room.model.thirdparty.RoomDirectoryData import im.vector.matrix.android.api.session.room.model.thirdparty.RoomDirectoryData
import im.vector.riotx.R import im.vector.riotx.R
import im.vector.riotx.core.platform.VectorBaseFragment import im.vector.riotx.core.platform.VectorBaseFragment
import im.vector.riotx.features.roomdirectory.RoomDirectoryAction
import im.vector.riotx.features.roomdirectory.RoomDirectoryActionViewModel import im.vector.riotx.features.roomdirectory.RoomDirectoryActionViewModel
import im.vector.riotx.features.roomdirectory.RoomDirectoryActivity
import im.vector.riotx.features.roomdirectory.RoomDirectoryViewModel import im.vector.riotx.features.roomdirectory.RoomDirectoryViewModel
import kotlinx.android.synthetic.main.fragment_room_directory_picker.* import kotlinx.android.synthetic.main.fragment_room_directory_picker.*
import timber.log.Timber import timber.log.Timber
@ -88,7 +88,7 @@ class RoomDirectoryPickerFragment @Inject constructor(val roomDirectoryPickerVie
Timber.v("onRoomDirectoryClicked: $roomDirectoryData") Timber.v("onRoomDirectoryClicked: $roomDirectoryData")
viewModel.setRoomDirectoryData(roomDirectoryData) viewModel.setRoomDirectoryData(roomDirectoryData)
actionViewModel.post(RoomDirectoryActivity.RoomDirectoryAction.Back) actionViewModel.post(RoomDirectoryAction.Back)
} }
override fun retry() { override fun retry() {