Rename stuff for code coherence

This commit is contained in:
Benoit Marty 2019-11-08 15:36:12 +01:00
parent 12376368c7
commit 631448335d
17 changed files with 60 additions and 60 deletions

View file

@ -47,7 +47,7 @@ import javax.inject.Inject
class HomeActivity : VectorBaseActivity(), ToolbarConfigurable { class HomeActivity : VectorBaseActivity(), ToolbarConfigurable {
private lateinit var actionViewModel: HomeSharedActionViewModel private lateinit var sharedActionViewModel: HomeSharedActionViewModel
@Inject lateinit var activeSessionHolder: ActiveSessionHolder @Inject lateinit var activeSessionHolder: ActiveSessionHolder
@Inject lateinit var vectorUncaughtExceptionHandler: VectorUncaughtExceptionHandler @Inject lateinit var vectorUncaughtExceptionHandler: VectorUncaughtExceptionHandler
@ -69,16 +69,16 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
FcmHelper.ensureFcmTokenIsRetrieved(this, pushManager) FcmHelper.ensureFcmTokenIsRetrieved(this, pushManager)
actionViewModel = ViewModelProviders.of(this).get(HomeSharedActionViewModel::class.java) sharedActionViewModel = ViewModelProviders.of(this).get(HomeSharedActionViewModel::class.java)
drawerLayout.addDrawerListener(drawerListener) drawerLayout.addDrawerListener(drawerListener)
if (isFirstCreation()) { if (isFirstCreation()) {
replaceFragment(R.id.homeDetailFragmentContainer, LoadingFragment::class.java) replaceFragment(R.id.homeDetailFragmentContainer, LoadingFragment::class.java)
replaceFragment(R.id.homeDrawerFragmentContainer, HomeDrawerFragment::class.java) replaceFragment(R.id.homeDrawerFragmentContainer, HomeDrawerFragment::class.java)
} }
actionViewModel.observe() sharedActionViewModel.observe()
.subscribe { navigation -> .subscribe { sharedAction ->
when (navigation) { when (sharedAction) {
is HomeActivitySharedAction.OpenDrawer -> drawerLayout.openDrawer(GravityCompat.START) is HomeActivitySharedAction.OpenDrawer -> drawerLayout.openDrawer(GravityCompat.START)
is HomeActivitySharedAction.OpenGroup -> { is HomeActivitySharedAction.OpenGroup -> {
drawerLayout.closeDrawer(GravityCompat.START) drawerLayout.closeDrawer(GravityCompat.START)

View file

@ -54,7 +54,7 @@ class HomeDetailFragment @Inject constructor(
private val unreadCounterBadgeViews = arrayListOf<UnreadCounterBadgeView>() private val unreadCounterBadgeViews = arrayListOf<UnreadCounterBadgeView>()
private val viewModel: HomeDetailViewModel by fragmentViewModel() private val viewModel: HomeDetailViewModel by fragmentViewModel()
private lateinit var actionViewModel: HomeSharedActionViewModel private lateinit var sharedActionViewModel: HomeSharedActionViewModel
override fun getLayoutResId(): Int { override fun getLayoutResId(): Int {
return R.layout.fragment_home_detail return R.layout.fragment_home_detail
@ -63,7 +63,7 @@ class HomeDetailFragment @Inject constructor(
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState) super.onActivityCreated(savedInstanceState)
actionViewModel = ViewModelProviders.of(requireActivity()).get(HomeSharedActionViewModel::class.java) sharedActionViewModel = ViewModelProviders.of(requireActivity()).get(HomeSharedActionViewModel::class.java)
setupBottomNavigationView() setupBottomNavigationView()
setupToolbar() setupToolbar()
@ -129,7 +129,7 @@ class HomeDetailFragment @Inject constructor(
} }
groupToolbar.title = "" groupToolbar.title = ""
groupToolbarAvatarImageView.setOnClickListener { groupToolbarAvatarImageView.setOnClickListener {
actionViewModel.post(HomeActivitySharedAction.OpenDrawer) sharedActionViewModel.post(HomeActivitySharedAction.OpenDrawer)
} }
} }

View file

@ -39,7 +39,7 @@ import javax.inject.Inject
class CreateDirectRoomActivity : SimpleFragmentActivity() { class CreateDirectRoomActivity : SimpleFragmentActivity() {
private val viewModel: CreateDirectRoomViewModel by viewModel() private val viewModel: CreateDirectRoomViewModel by viewModel()
private lateinit var actionViewModel: CreateDirectRoomSharedActionViewModel private lateinit var sharedActionViewModel: CreateDirectRoomSharedActionViewModel
@Inject lateinit var createDirectRoomViewModelFactory: CreateDirectRoomViewModel.Factory @Inject lateinit var createDirectRoomViewModelFactory: CreateDirectRoomViewModel.Factory
@Inject lateinit var errorFormatter: ErrorFormatter @Inject lateinit var errorFormatter: ErrorFormatter
@ -51,10 +51,10 @@ class CreateDirectRoomActivity : SimpleFragmentActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
toolbar.visibility = View.GONE toolbar.visibility = View.GONE
actionViewModel = ViewModelProviders.of(this, viewModelFactory).get(CreateDirectRoomSharedActionViewModel::class.java) sharedActionViewModel = ViewModelProviders.of(this, viewModelFactory).get(CreateDirectRoomSharedActionViewModel::class.java)
actionViewModel.observe() sharedActionViewModel.observe()
.subscribe { navigation -> .subscribe { sharedAction ->
when (navigation) { when (sharedAction) {
CreateDirectRoomSharedAction.OpenUsersDirectory -> addFragmentToBackstack(R.id.container, CreateDirectRoomDirectoryUsersFragment::class.java) CreateDirectRoomSharedAction.OpenUsersDirectory -> addFragmentToBackstack(R.id.container, CreateDirectRoomDirectoryUsersFragment::class.java)
CreateDirectRoomSharedAction.Close -> finish() CreateDirectRoomSharedAction.Close -> finish()
CreateDirectRoomSharedAction.GoBack -> onBackPressed() CreateDirectRoomSharedAction.GoBack -> onBackPressed()

View file

@ -39,11 +39,11 @@ class CreateDirectRoomDirectoryUsersFragment @Inject constructor(
private val viewModel: CreateDirectRoomViewModel by activityViewModel() private val viewModel: CreateDirectRoomViewModel by activityViewModel()
private lateinit var actionViewModel: CreateDirectRoomSharedActionViewModel private lateinit var sharedActionViewModel: CreateDirectRoomSharedActionViewModel
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState) super.onActivityCreated(savedInstanceState)
actionViewModel = ViewModelProviders.of(requireActivity(), viewModelFactory).get(CreateDirectRoomSharedActionViewModel::class.java) sharedActionViewModel = ViewModelProviders.of(requireActivity(), viewModelFactory).get(CreateDirectRoomSharedActionViewModel::class.java)
setupRecyclerView() setupRecyclerView()
setupSearchByMatrixIdView() setupSearchByMatrixIdView()
setupCloseView() setupCloseView()
@ -70,7 +70,7 @@ class CreateDirectRoomDirectoryUsersFragment @Inject constructor(
private fun setupCloseView() { private fun setupCloseView() {
createDirectRoomClose.setOnClickListener { createDirectRoomClose.setOnClickListener {
actionViewModel.post(CreateDirectRoomSharedAction.GoBack) sharedActionViewModel.post(CreateDirectRoomSharedAction.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(CreateDirectRoomAction.SelectUser(user)) viewModel.handle(CreateDirectRoomAction.SelectUser(user))
actionViewModel.post(CreateDirectRoomSharedAction.GoBack) sharedActionViewModel.post(CreateDirectRoomSharedAction.GoBack)
} }
override fun retryDirectoryUsersRequest() { override fun retryDirectoryUsersRequest() {

View file

@ -49,11 +49,11 @@ class CreateDirectRoomKnownUsersFragment @Inject constructor(
override fun getMenuRes() = R.menu.vector_create_direct_room override fun getMenuRes() = R.menu.vector_create_direct_room
private val viewModel: CreateDirectRoomViewModel by activityViewModel() private val viewModel: CreateDirectRoomViewModel by activityViewModel()
private lateinit var actionViewModel: CreateDirectRoomSharedActionViewModel private lateinit var sharedActionViewModel: CreateDirectRoomSharedActionViewModel
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState) super.onActivityCreated(savedInstanceState)
actionViewModel = ViewModelProviders.of(requireActivity(), viewModelFactory).get(CreateDirectRoomSharedActionViewModel::class.java) sharedActionViewModel = ViewModelProviders.of(requireActivity(), viewModelFactory).get(CreateDirectRoomSharedActionViewModel::class.java)
vectorBaseActivity.setSupportActionBar(createDirectRoomToolbar) vectorBaseActivity.setSupportActionBar(createDirectRoomToolbar)
setupRecyclerView() setupRecyclerView()
setupFilterView() setupFilterView()
@ -89,7 +89,7 @@ class CreateDirectRoomKnownUsersFragment @Inject constructor(
private fun setupAddByMatrixIdView() { private fun setupAddByMatrixIdView() {
addByMatrixId.setOnClickListener { addByMatrixId.setOnClickListener {
actionViewModel.post(CreateDirectRoomSharedAction.OpenUsersDirectory) sharedActionViewModel.post(CreateDirectRoomSharedAction.OpenUsersDirectory)
} }
} }

View file

@ -36,20 +36,20 @@ class GroupListFragment @Inject constructor(
private val groupController: GroupSummaryController private val groupController: GroupSummaryController
) : VectorBaseFragment(), GroupSummaryController.Callback { ) : VectorBaseFragment(), GroupSummaryController.Callback {
private lateinit var actionViewModel: HomeSharedActionViewModel private lateinit var sharedActionViewModel: HomeSharedActionViewModel
private val viewModel: GroupListViewModel by fragmentViewModel() private val viewModel: GroupListViewModel by fragmentViewModel()
override fun getLayoutResId() = R.layout.fragment_group_list override fun getLayoutResId() = R.layout.fragment_group_list
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState) super.onActivityCreated(savedInstanceState)
actionViewModel = ViewModelProviders.of(requireActivity()).get(HomeSharedActionViewModel::class.java) sharedActionViewModel = ViewModelProviders.of(requireActivity()).get(HomeSharedActionViewModel::class.java)
groupController.callback = this groupController.callback = this
stateView.contentView = groupListEpoxyRecyclerView stateView.contentView = groupListEpoxyRecyclerView
groupListEpoxyRecyclerView.setController(groupController) groupListEpoxyRecyclerView.setController(groupController)
viewModel.subscribe { renderState(it) } viewModel.subscribe { renderState(it) }
viewModel.openGroupLiveData.observeEvent(this) { viewModel.openGroupLiveData.observeEvent(this) {
actionViewModel.post(HomeActivitySharedAction.OpenGroup) sharedActionViewModel.post(HomeActivitySharedAction.OpenGroup)
} }
} }

View file

@ -98,7 +98,7 @@ import im.vector.riotx.features.home.room.detail.composer.TextComposerViewState
import im.vector.riotx.features.home.room.detail.readreceipts.DisplayReadReceiptsBottomSheet import im.vector.riotx.features.home.room.detail.readreceipts.DisplayReadReceiptsBottomSheet
import im.vector.riotx.features.home.room.detail.timeline.TimelineEventController import im.vector.riotx.features.home.room.detail.timeline.TimelineEventController
import im.vector.riotx.features.home.room.detail.timeline.action.MessageActionsBottomSheet import im.vector.riotx.features.home.room.detail.timeline.action.MessageActionsBottomSheet
import im.vector.riotx.features.home.room.detail.timeline.action.MessageActionsDispatcher import im.vector.riotx.features.home.room.detail.timeline.action.MessageSharedActionViewModel
import im.vector.riotx.features.home.room.detail.timeline.action.EventSharedAction import im.vector.riotx.features.home.room.detail.timeline.action.EventSharedAction
import im.vector.riotx.features.home.room.detail.timeline.edithistory.ViewEditHistoryBottomSheet import im.vector.riotx.features.home.room.detail.timeline.edithistory.ViewEditHistoryBottomSheet
import im.vector.riotx.features.home.room.detail.timeline.item.* import im.vector.riotx.features.home.room.detail.timeline.item.*
@ -193,7 +193,7 @@ class RoomDetailFragment @Inject constructor(
override fun getMenuRes() = R.menu.menu_timeline override fun getMenuRes() = R.menu.menu_timeline
private lateinit var messageActionsDispatcher: MessageActionsDispatcher private lateinit var sharedActionViewModel: MessageSharedActionViewModel
private lateinit var layoutManager: LinearLayoutManager private lateinit var layoutManager: LinearLayoutManager
private lateinit var attachmentsHelper: AttachmentsHelper private lateinit var attachmentsHelper: AttachmentsHelper
private lateinit var keyboardStateUtils: KeyboardStateUtils private lateinit var keyboardStateUtils: KeyboardStateUtils
@ -206,7 +206,7 @@ class RoomDetailFragment @Inject constructor(
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState) super.onActivityCreated(savedInstanceState)
messageActionsDispatcher = ViewModelProviders.of(requireActivity()).get(MessageActionsDispatcher::class.java) sharedActionViewModel = ViewModelProviders.of(requireActivity()).get(MessageSharedActionViewModel::class.java)
attachmentsHelper = AttachmentsHelper.create(this, this).register() attachmentsHelper = AttachmentsHelper.create(this, this).register()
keyboardStateUtils = KeyboardStateUtils(requireActivity()) keyboardStateUtils = KeyboardStateUtils(requireActivity())
setupToolbar(roomToolbar) setupToolbar(roomToolbar)
@ -225,7 +225,7 @@ class RoomDetailFragment @Inject constructor(
val message = requireContext().getString(pair.first, *pair.second.toTypedArray()) val message = requireContext().getString(pair.first, *pair.second.toTypedArray())
showSnackWithMessage(message, Snackbar.LENGTH_LONG) showSnackWithMessage(message, Snackbar.LENGTH_LONG)
} }
messageActionsDispatcher sharedActionViewModel
.observe() .observe()
.subscribe { .subscribe {
handleActions(it) handleActions(it)

View file

@ -47,7 +47,7 @@ class MessageActionsBottomSheet : VectorBaseBottomSheetDialogFragment(), Message
override val showExpanded = true override val showExpanded = true
private lateinit var messageActionsStore: MessageActionsDispatcher private lateinit var sharedActionViewModel: MessageSharedActionViewModel
override fun injectWith(screenComponent: ScreenComponent) { override fun injectWith(screenComponent: ScreenComponent) {
screenComponent.inject(this) screenComponent.inject(this)
@ -61,7 +61,7 @@ class MessageActionsBottomSheet : VectorBaseBottomSheetDialogFragment(), Message
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState) super.onActivityCreated(savedInstanceState)
messageActionsStore = ViewModelProviders.of(requireActivity()).get(MessageActionsDispatcher::class.java) sharedActionViewModel = ViewModelProviders.of(requireActivity()).get(MessageSharedActionViewModel::class.java)
recyclerView.layoutManager = LinearLayoutManager(requireContext(), RecyclerView.VERTICAL, false) recyclerView.layoutManager = LinearLayoutManager(requireContext(), RecyclerView.VERTICAL, false)
recyclerView.adapter = messageActionsEpoxyController.adapter recyclerView.adapter = messageActionsEpoxyController.adapter
// Disable item animation // Disable item animation
@ -74,7 +74,7 @@ class MessageActionsBottomSheet : VectorBaseBottomSheetDialogFragment(), Message
// Toggle report menu // Toggle report menu
viewModel.handle(MessageActionsAction.ToggleReportMenu) viewModel.handle(MessageActionsAction.ToggleReportMenu)
} else { } else {
messageActionsStore.post(eventAction) sharedActionViewModel.post(eventAction)
dismiss() dismiss()
} }
} }

View file

@ -20,4 +20,4 @@ import im.vector.riotx.core.platform.VectorSharedActionViewModel
/** /**
* Activity shared view model to handle message actions * Activity shared view model to handle message actions
*/ */
class MessageActionsDispatcher : VectorSharedActionViewModel<EventSharedAction>() class MessageSharedActionViewModel : VectorSharedActionViewModel<EventSharedAction>()

View file

@ -41,7 +41,7 @@ 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.room.list.actions.RoomListQuickActionsSharedAction import im.vector.riotx.features.home.room.list.actions.RoomListQuickActionsSharedAction
import im.vector.riotx.features.home.room.list.actions.RoomListQuickActionsBottomSheet import im.vector.riotx.features.home.room.list.actions.RoomListQuickActionsBottomSheet
import im.vector.riotx.features.home.room.list.actions.RoomListQuickActionsStore import im.vector.riotx.features.home.room.list.actions.RoomListQuickActionsSharedActionViewModel
import im.vector.riotx.features.home.room.list.widget.FabMenuView import im.vector.riotx.features.home.room.list.widget.FabMenuView
import im.vector.riotx.features.notifications.NotificationDrawerManager import im.vector.riotx.features.notifications.NotificationDrawerManager
import im.vector.riotx.features.share.SharedData import im.vector.riotx.features.share.SharedData
@ -72,7 +72,7 @@ class RoomListFragment @Inject constructor(
SHARE(/* Not used */ 0) SHARE(/* Not used */ 0)
} }
private lateinit var quickActionsDispatcher: RoomListQuickActionsStore private lateinit var sharedActionViewModel: RoomListQuickActionsSharedActionViewModel
private val roomListParams: RoomListParams by args() private val roomListParams: RoomListParams by args()
private val roomListViewModel: RoomListViewModel by fragmentViewModel() private val roomListViewModel: RoomListViewModel by fragmentViewModel()
@ -100,7 +100,7 @@ class RoomListFragment @Inject constructor(
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState) super.onActivityCreated(savedInstanceState)
quickActionsDispatcher = ViewModelProviders.of(requireActivity()).get(RoomListQuickActionsStore::class.java) sharedActionViewModel = ViewModelProviders.of(requireActivity()).get(RoomListQuickActionsSharedActionViewModel::class.java)
setupCreateRoomButton() setupCreateRoomButton()
setupRecyclerView() setupRecyclerView()
roomListViewModel.subscribe { renderState(it) } roomListViewModel.subscribe { renderState(it) }
@ -118,7 +118,7 @@ class RoomListFragment @Inject constructor(
createChatFabMenu.listener = this createChatFabMenu.listener = this
quickActionsDispatcher sharedActionViewModel
.observe() .observe()
.subscribe { handleQuickActions(it) } .subscribe { handleQuickActions(it) }
.disposeOnDestroy() .disposeOnDestroy()

View file

@ -45,7 +45,7 @@ data class RoomListActionsArgs(
*/ */
class RoomListQuickActionsBottomSheet : VectorBaseBottomSheetDialogFragment(), RoomListQuickActionsEpoxyController.Listener { class RoomListQuickActionsBottomSheet : VectorBaseBottomSheetDialogFragment(), RoomListQuickActionsEpoxyController.Listener {
private lateinit var actionsDispatcher: RoomListQuickActionsStore private lateinit var sharedActionViewModel: RoomListQuickActionsSharedActionViewModel
@Inject lateinit var roomListActionsViewModelFactory: RoomListQuickActionsViewModel.Factory @Inject lateinit var roomListActionsViewModelFactory: RoomListQuickActionsViewModel.Factory
@Inject lateinit var roomListActionsEpoxyController: RoomListQuickActionsEpoxyController @Inject lateinit var roomListActionsEpoxyController: RoomListQuickActionsEpoxyController
@Inject lateinit var navigator: Navigator @Inject lateinit var navigator: Navigator
@ -69,7 +69,7 @@ class RoomListQuickActionsBottomSheet : VectorBaseBottomSheetDialogFragment(), R
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState) super.onActivityCreated(savedInstanceState)
actionsDispatcher = ViewModelProviders.of(requireActivity()).get(RoomListQuickActionsStore::class.java) sharedActionViewModel = ViewModelProviders.of(requireActivity()).get(RoomListQuickActionsSharedActionViewModel::class.java)
recyclerView.layoutManager = LinearLayoutManager(requireContext(), RecyclerView.VERTICAL, false) recyclerView.layoutManager = LinearLayoutManager(requireContext(), RecyclerView.VERTICAL, false)
recyclerView.adapter = roomListActionsEpoxyController.adapter recyclerView.adapter = roomListActionsEpoxyController.adapter
// Disable item animation // Disable item animation
@ -83,7 +83,7 @@ class RoomListQuickActionsBottomSheet : VectorBaseBottomSheetDialogFragment(), R
} }
override fun didSelectMenuAction(quickAction: RoomListQuickActionsSharedAction) { override fun didSelectMenuAction(quickAction: RoomListQuickActionsSharedAction) {
actionsDispatcher.post(quickAction) sharedActionViewModel.post(quickAction)
dismiss() dismiss()
} }

View file

@ -21,4 +21,4 @@ import im.vector.riotx.core.platform.VectorSharedActionViewModel
/** /**
* Activity shared view model to handle room list quick actions * Activity shared view model to handle room list quick actions
*/ */
class RoomListQuickActionsStore : VectorSharedActionViewModel<RoomListQuickActionsSharedAction>() class RoomListQuickActionsSharedActionViewModel : VectorSharedActionViewModel<RoomListQuickActionsSharedAction>()

View file

@ -47,7 +47,7 @@ class PublicRoomsFragment @Inject constructor(
) : VectorBaseFragment(), PublicRoomsController.Callback { ) : VectorBaseFragment(), PublicRoomsController.Callback {
private val viewModel: RoomDirectoryViewModel by activityViewModel() private val viewModel: RoomDirectoryViewModel by activityViewModel()
private lateinit var actionViewModel: RoomDirectorySharedActionViewModel private lateinit var sharedActionViewModel: RoomDirectorySharedActionViewModel
override fun getLayoutResId() = R.layout.fragment_public_rooms override fun getLayoutResId() = R.layout.fragment_public_rooms
@ -71,7 +71,7 @@ class PublicRoomsFragment @Inject constructor(
.disposeOnDestroy() .disposeOnDestroy()
publicRoomsCreateNewRoom.setOnClickListener { publicRoomsCreateNewRoom.setOnClickListener {
actionViewModel.post(RoomDirectorySharedAction.CreateRoom) sharedActionViewModel.post(RoomDirectorySharedAction.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(RoomDirectorySharedAction.ChangeProtocol) sharedActionViewModel.post(RoomDirectorySharedAction.ChangeProtocol)
true true
} }
else -> else ->
@ -93,7 +93,7 @@ class PublicRoomsFragment @Inject constructor(
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState) super.onActivityCreated(savedInstanceState)
actionViewModel = ViewModelProviders.of(requireActivity()).get(RoomDirectorySharedActionViewModel::class.java) sharedActionViewModel = ViewModelProviders.of(requireActivity()).get(RoomDirectorySharedActionViewModel::class.java)
setupRecyclerView() setupRecyclerView()
} }

View file

@ -38,7 +38,7 @@ class RoomDirectoryActivity : VectorBaseActivity() {
@Inject lateinit var roomDirectoryViewModelFactory: RoomDirectoryViewModel.Factory @Inject lateinit var roomDirectoryViewModelFactory: RoomDirectoryViewModel.Factory
private val roomDirectoryViewModel: RoomDirectoryViewModel by viewModel() private val roomDirectoryViewModel: RoomDirectoryViewModel by viewModel()
private val createRoomViewModel: CreateRoomViewModel by viewModel() private val createRoomViewModel: CreateRoomViewModel by viewModel()
private lateinit var actionViewModel: RoomDirectorySharedActionViewModel private lateinit var sharedActionViewModel: RoomDirectorySharedActionViewModel
override fun getLayoutRes() = R.layout.activity_simple override fun getLayoutRes() = R.layout.activity_simple
@ -48,15 +48,15 @@ class RoomDirectoryActivity : VectorBaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
actionViewModel = ViewModelProviders.of(this, viewModelFactory).get(RoomDirectorySharedActionViewModel::class.java) sharedActionViewModel = ViewModelProviders.of(this, viewModelFactory).get(RoomDirectorySharedActionViewModel::class.java)
if (isFirstCreation()) { if (isFirstCreation()) {
roomDirectoryViewModel.handle(RoomDirectoryAction.FilterWith(intent?.getStringExtra(INITIAL_FILTER) ?: "")) roomDirectoryViewModel.handle(RoomDirectoryAction.FilterWith(intent?.getStringExtra(INITIAL_FILTER) ?: ""))
} }
actionViewModel.observe() sharedActionViewModel.observe()
.subscribe { navigation -> .subscribe { sharedAction ->
when (navigation) { when (sharedAction) {
is RoomDirectorySharedAction.Back -> onBackPressed() is RoomDirectorySharedAction.Back -> onBackPressed()
is RoomDirectorySharedAction.CreateRoom -> addFragmentToBackstack(R.id.simpleFragmentContainer, CreateRoomFragment::class.java) is RoomDirectorySharedAction.CreateRoom -> addFragmentToBackstack(R.id.simpleFragmentContainer, CreateRoomFragment::class.java)
is RoomDirectorySharedAction.ChangeProtocol -> addFragmentToBackstack(R.id.simpleFragmentContainer, RoomDirectoryPickerFragment::class.java) is RoomDirectorySharedAction.ChangeProtocol -> addFragmentToBackstack(R.id.simpleFragmentContainer, RoomDirectoryPickerFragment::class.java)

View file

@ -38,7 +38,7 @@ class CreateRoomActivity : VectorBaseActivity(), ToolbarConfigurable {
@Inject lateinit var createRoomViewModelFactory: CreateRoomViewModel.Factory @Inject lateinit var createRoomViewModelFactory: CreateRoomViewModel.Factory
private val createRoomViewModel: CreateRoomViewModel by viewModel() private val createRoomViewModel: CreateRoomViewModel by viewModel()
private lateinit var actionViewModel: RoomDirectorySharedActionViewModel private lateinit var sharedActionViewModel: RoomDirectorySharedActionViewModel
override fun getLayoutRes() = R.layout.activity_simple override fun getLayoutRes() = R.layout.activity_simple
@ -55,10 +55,10 @@ class CreateRoomActivity : VectorBaseActivity(), ToolbarConfigurable {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
actionViewModel = ViewModelProviders.of(this, viewModelFactory).get(RoomDirectorySharedActionViewModel::class.java) sharedActionViewModel = ViewModelProviders.of(this, viewModelFactory).get(RoomDirectorySharedActionViewModel::class.java)
actionViewModel.observe() sharedActionViewModel.observe()
.subscribe { navigation -> .subscribe { sharedAction ->
when (navigation) { when (sharedAction) {
is RoomDirectorySharedAction.Back, is RoomDirectorySharedAction.Back,
is RoomDirectorySharedAction.Close -> finish() is RoomDirectorySharedAction.Close -> finish()
} }

View file

@ -33,7 +33,7 @@ import javax.inject.Inject
class CreateRoomFragment @Inject constructor(private val createRoomController: CreateRoomController) : VectorBaseFragment(), CreateRoomController.Listener { class CreateRoomFragment @Inject constructor(private val createRoomController: CreateRoomController) : VectorBaseFragment(), CreateRoomController.Listener {
private lateinit var actionViewModel: RoomDirectorySharedActionViewModel private lateinit var sharedActionViewModel: RoomDirectorySharedActionViewModel
private val viewModel: CreateRoomViewModel by activityViewModel() private val viewModel: CreateRoomViewModel by activityViewModel()
override fun getLayoutResId() = R.layout.fragment_create_room override fun getLayoutResId() = R.layout.fragment_create_room
@ -43,10 +43,10 @@ class CreateRoomFragment @Inject constructor(private val createRoomController: C
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState) super.onActivityCreated(savedInstanceState)
vectorBaseActivity.setSupportActionBar(createRoomToolbar) vectorBaseActivity.setSupportActionBar(createRoomToolbar)
actionViewModel = ViewModelProviders.of(requireActivity()).get(RoomDirectorySharedActionViewModel::class.java) sharedActionViewModel = ViewModelProviders.of(requireActivity()).get(RoomDirectorySharedActionViewModel::class.java)
setupRecyclerView() setupRecyclerView()
createRoomClose.setOnClickListener { createRoomClose.setOnClickListener {
actionViewModel.post(RoomDirectorySharedAction.Back) sharedActionViewModel.post(RoomDirectorySharedAction.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(RoomDirectorySharedAction.Close) sharedActionViewModel.post(RoomDirectorySharedAction.Close)
} else { } else {
// Populate list with Epoxy // Populate list with Epoxy
createRoomController.setData(state) createRoomController.setData(state)

View file

@ -42,7 +42,7 @@ class RoomDirectoryPickerFragment @Inject constructor(val roomDirectoryPickerVie
) : VectorBaseFragment(), RoomDirectoryPickerController.Callback { ) : VectorBaseFragment(), RoomDirectoryPickerController.Callback {
private val viewModel: RoomDirectoryViewModel by activityViewModel() private val viewModel: RoomDirectoryViewModel by activityViewModel()
private lateinit var actionViewModel: RoomDirectorySharedActionViewModel private lateinit var sharedActionViewModel: RoomDirectorySharedActionViewModel
private val pickerViewModel: RoomDirectoryPickerViewModel by fragmentViewModel() private val pickerViewModel: RoomDirectoryPickerViewModel by fragmentViewModel()
override fun getLayoutResId() = R.layout.fragment_room_directory_picker override fun getLayoutResId() = R.layout.fragment_room_directory_picker
@ -72,7 +72,7 @@ class RoomDirectoryPickerFragment @Inject constructor(val roomDirectoryPickerVie
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState) super.onActivityCreated(savedInstanceState)
actionViewModel = ViewModelProviders.of(requireActivity()).get(RoomDirectorySharedActionViewModel::class.java) sharedActionViewModel = ViewModelProviders.of(requireActivity()).get(RoomDirectorySharedActionViewModel::class.java)
setupRecyclerView() setupRecyclerView()
} }
@ -89,7 +89,7 @@ class RoomDirectoryPickerFragment @Inject constructor(val roomDirectoryPickerVie
Timber.v("onRoomDirectoryClicked: $roomDirectoryData") Timber.v("onRoomDirectoryClicked: $roomDirectoryData")
viewModel.handle(RoomDirectoryAction.SetRoomDirectoryData(roomDirectoryData)) viewModel.handle(RoomDirectoryAction.SetRoomDirectoryData(roomDirectoryData))
actionViewModel.post(RoomDirectorySharedAction.Back) sharedActionViewModel.post(RoomDirectorySharedAction.Back)
} }
override fun retry() { override fun retry() {