mirror of
https://github.com/element-hq/element-android
synced 2024-11-25 02:45:37 +03:00
Move class to dedicated file
This commit is contained in:
parent
fa5d44af65
commit
c8bc553caa
18 changed files with 100 additions and 43 deletions
|
@ -18,4 +18,4 @@ package im.vector.riotx.features.home
|
|||
|
||||
import im.vector.riotx.core.platform.VectorActionViewModel
|
||||
|
||||
class HomeActionViewModel : VectorActionViewModel<HomeActivity.HomeActivityAction>()
|
||||
class HomeActionViewModel : VectorActionViewModel<HomeActivityAction>()
|
||||
|
|
|
@ -33,7 +33,6 @@ import im.vector.riotx.core.di.ScreenComponent
|
|||
import im.vector.riotx.core.extensions.hideKeyboard
|
||||
import im.vector.riotx.core.extensions.replaceFragment
|
||||
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.pushers.PushersManager
|
||||
import im.vector.riotx.features.disclaimer.showDisclaimerDialog
|
||||
|
@ -48,12 +47,6 @@ import javax.inject.Inject
|
|||
|
||||
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
|
||||
|
||||
@Inject lateinit var activeSessionHolder: ActiveSessionHolder
|
||||
|
|
|
@ -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()
|
||||
}
|
|
@ -129,7 +129,7 @@ class HomeDetailFragment @Inject constructor(
|
|||
}
|
||||
groupToolbar.title = ""
|
||||
groupToolbarAvatarImageView.setOnClickListener {
|
||||
actionViewModel.post(HomeActivity.HomeActivityAction.OpenDrawer)
|
||||
actionViewModel.post(HomeActivityAction.OpenDrawer)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
}
|
|
@ -18,4 +18,4 @@ package im.vector.riotx.features.home.createdirect
|
|||
|
||||
import im.vector.riotx.core.platform.VectorActionViewModel
|
||||
|
||||
class CreateDirectRoomActionViewModel : VectorActionViewModel<CreateDirectRoomActivity.CreateDirectRoomAction>()
|
||||
class CreateDirectRoomActionViewModel : VectorActionViewModel<CreateDirectRoomAction>()
|
||||
|
|
|
@ -19,7 +19,6 @@ package im.vector.riotx.features.home.createdirect
|
|||
import im.vector.matrix.android.api.session.user.model.User
|
||||
|
||||
sealed class CreateDirectRoomActions {
|
||||
|
||||
object CreateRoomAndInviteSelectedUsers : CreateDirectRoomActions()
|
||||
data class FilterKnownUsers(val value: String) : CreateDirectRoomActions()
|
||||
data class SearchDirectoryUsers(val value: String) : CreateDirectRoomActions()
|
||||
|
|
|
@ -32,19 +32,12 @@ import im.vector.riotx.core.error.ErrorFormatter
|
|||
import im.vector.riotx.core.extensions.addFragment
|
||||
import im.vector.riotx.core.extensions.addFragmentToBackstack
|
||||
import im.vector.riotx.core.platform.SimpleFragmentActivity
|
||||
import im.vector.riotx.core.platform.VectorAction
|
||||
import im.vector.riotx.core.platform.WaitingViewData
|
||||
import kotlinx.android.synthetic.main.activity.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class CreateDirectRoomActivity : SimpleFragmentActivity() {
|
||||
|
||||
sealed class CreateDirectRoomAction : VectorAction {
|
||||
object OpenUsersDirectory : CreateDirectRoomAction()
|
||||
object Close : CreateDirectRoomAction()
|
||||
object GoBack : CreateDirectRoomAction()
|
||||
}
|
||||
|
||||
private val viewModel: CreateDirectRoomViewModel by viewModel()
|
||||
private lateinit var actionViewModel: CreateDirectRoomActionViewModel
|
||||
@Inject lateinit var createDirectRoomViewModelFactory: CreateDirectRoomViewModel.Factory
|
||||
|
|
|
@ -70,7 +70,7 @@ class CreateDirectRoomDirectoryUsersFragment @Inject constructor(
|
|||
|
||||
private fun setupCloseView() {
|
||||
createDirectRoomClose.setOnClickListener {
|
||||
actionViewModel.post(CreateDirectRoomActivity.CreateDirectRoomAction.GoBack)
|
||||
actionViewModel.post(CreateDirectRoomAction.GoBack)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ class CreateDirectRoomDirectoryUsersFragment @Inject constructor(
|
|||
override fun onItemClick(user: User) {
|
||||
view?.hideKeyboard()
|
||||
viewModel.handle(CreateDirectRoomActions.SelectUser(user))
|
||||
actionViewModel.post(CreateDirectRoomActivity.CreateDirectRoomAction.GoBack)
|
||||
actionViewModel.post(CreateDirectRoomAction.GoBack)
|
||||
}
|
||||
|
||||
override fun retryDirectoryUsersRequest() {
|
||||
|
|
|
@ -89,7 +89,7 @@ class CreateDirectRoomKnownUsersFragment @Inject constructor(
|
|||
|
||||
private fun setupAddByMatrixIdView() {
|
||||
addByMatrixId.setOnClickListener {
|
||||
actionViewModel.post(CreateDirectRoomActivity.CreateDirectRoomAction.OpenUsersDirectory)
|
||||
actionViewModel.post(CreateDirectRoomAction.OpenUsersDirectory)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ import im.vector.riotx.core.extensions.observeEvent
|
|||
import im.vector.riotx.core.platform.StateView
|
||||
import im.vector.riotx.core.platform.VectorBaseFragment
|
||||
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 javax.inject.Inject
|
||||
|
||||
|
@ -49,7 +49,7 @@ class GroupListFragment @Inject constructor(
|
|||
groupListEpoxyRecyclerView.setController(groupController)
|
||||
viewModel.subscribe { renderState(it) }
|
||||
viewModel.openGroupLiveData.observeEvent(this) {
|
||||
actionViewModel.post(HomeActivity.HomeActivityAction.OpenGroup)
|
||||
actionViewModel.post(HomeActivityAction.OpenGroup)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ class PublicRoomsFragment @Inject constructor(
|
|||
.disposeOnDestroy()
|
||||
|
||||
publicRoomsCreateNewRoom.setOnClickListener {
|
||||
actionViewModel.post(RoomDirectoryActivity.RoomDirectoryAction.CreateRoom)
|
||||
actionViewModel.post(RoomDirectoryAction.CreateRoom)
|
||||
}
|
||||
|
||||
viewModel.joinRoomErrorLiveData.observeEvent(this) { throwable ->
|
||||
|
@ -83,7 +83,7 @@ class PublicRoomsFragment @Inject constructor(
|
|||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return when (item.itemId) {
|
||||
R.id.menu_room_directory_change_protocol -> {
|
||||
actionViewModel.post(RoomDirectoryActivity.RoomDirectoryAction.ChangeProtocol)
|
||||
actionViewModel.post(RoomDirectoryAction.ChangeProtocol)
|
||||
true
|
||||
}
|
||||
else ->
|
||||
|
|
|
@ -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()
|
||||
}
|
|
@ -18,4 +18,4 @@ package im.vector.riotx.features.roomdirectory
|
|||
|
||||
import im.vector.riotx.core.platform.VectorActionViewModel
|
||||
|
||||
class RoomDirectoryActionViewModel : VectorActionViewModel<RoomDirectoryActivity.RoomDirectoryAction>()
|
||||
class RoomDirectoryActionViewModel : VectorActionViewModel<RoomDirectoryAction>()
|
||||
|
|
|
@ -25,7 +25,6 @@ import im.vector.riotx.R
|
|||
import im.vector.riotx.core.di.ScreenComponent
|
||||
import im.vector.riotx.core.extensions.addFragment
|
||||
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.features.roomdirectory.createroom.CreateRoomFragment
|
||||
import im.vector.riotx.features.roomdirectory.createroom.CreateRoomViewModel
|
||||
|
@ -34,14 +33,6 @@ import javax.inject.Inject
|
|||
|
||||
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 roomDirectoryViewModelFactory: RoomDirectoryViewModel.Factory
|
||||
private val roomDirectoryViewModel: RoomDirectoryViewModel by viewModel()
|
||||
|
|
|
@ -26,7 +26,7 @@ import im.vector.riotx.R
|
|||
import im.vector.riotx.core.extensions.addFragment
|
||||
import im.vector.riotx.core.platform.ToolbarConfigurable
|
||||
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 javax.inject.Inject
|
||||
|
||||
|
@ -59,8 +59,8 @@ class CreateRoomActivity : VectorBaseActivity(), ToolbarConfigurable {
|
|||
actionViewModel.observe()
|
||||
.subscribe { navigation ->
|
||||
when (navigation) {
|
||||
is RoomDirectoryActivity.RoomDirectoryAction.Back,
|
||||
is RoomDirectoryActivity.RoomDirectoryAction.Close -> finish()
|
||||
is RoomDirectoryAction.Back,
|
||||
is RoomDirectoryAction.Close -> finish()
|
||||
}
|
||||
}
|
||||
.disposeOnDestroy()
|
||||
|
|
|
@ -25,7 +25,7 @@ import com.airbnb.mvrx.activityViewModel
|
|||
import com.airbnb.mvrx.withState
|
||||
import im.vector.riotx.R
|
||||
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 kotlinx.android.synthetic.main.fragment_create_room.*
|
||||
import timber.log.Timber
|
||||
|
@ -46,7 +46,7 @@ class CreateRoomFragment @Inject constructor(private val createRoomController: C
|
|||
actionViewModel = ViewModelProviders.of(requireActivity()).get(RoomDirectoryActionViewModel::class.java)
|
||||
setupRecyclerView()
|
||||
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
|
||||
navigator.openRoom(requireActivity(), async())
|
||||
|
||||
actionViewModel.post(RoomDirectoryActivity.RoomDirectoryAction.Close)
|
||||
actionViewModel.post(RoomDirectoryAction.Close)
|
||||
} else {
|
||||
// Populate list with Epoxy
|
||||
createRoomController.setData(state)
|
||||
|
|
|
@ -27,8 +27,8 @@ import com.airbnb.mvrx.withState
|
|||
import im.vector.matrix.android.api.session.room.model.thirdparty.RoomDirectoryData
|
||||
import im.vector.riotx.R
|
||||
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.RoomDirectoryActivity
|
||||
import im.vector.riotx.features.roomdirectory.RoomDirectoryViewModel
|
||||
import kotlinx.android.synthetic.main.fragment_room_directory_picker.*
|
||||
import timber.log.Timber
|
||||
|
@ -88,7 +88,7 @@ class RoomDirectoryPickerFragment @Inject constructor(val roomDirectoryPickerVie
|
|||
Timber.v("onRoomDirectoryClicked: $roomDirectoryData")
|
||||
viewModel.setRoomDirectoryData(roomDirectoryData)
|
||||
|
||||
actionViewModel.post(RoomDirectoryActivity.RoomDirectoryAction.Back)
|
||||
actionViewModel.post(RoomDirectoryAction.Back)
|
||||
}
|
||||
|
||||
override fun retry() {
|
||||
|
|
Loading…
Reference in a new issue