Refactor location sharing view events.

This commit is contained in:
Onuray Sahin 2022-04-01 12:31:51 +03:00
parent 20cdf2bef1
commit 5ec63858ed
3 changed files with 6 additions and 12 deletions

View file

@ -83,6 +83,5 @@ sealed class RoomDetailViewEvents : VectorViewEvents {
object StopChatEffects : RoomDetailViewEvents() object StopChatEffects : RoomDetailViewEvents()
object RoomReplacementStarted : RoomDetailViewEvents() object RoomReplacementStarted : RoomDetailViewEvents()
object ShowLocationSharingIndicator : RoomDetailViewEvents() data class ChangeLocationIndicator(val isVisible: Boolean) : RoomDetailViewEvents()
object HideLocationSharingIndicator : RoomDetailViewEvents()
} }

View file

@ -482,8 +482,7 @@ class TimelineFragment @Inject constructor(
RoomDetailViewEvents.StopChatEffects -> handleStopChatEffects() RoomDetailViewEvents.StopChatEffects -> handleStopChatEffects()
is RoomDetailViewEvents.DisplayAndAcceptCall -> acceptIncomingCall(it) is RoomDetailViewEvents.DisplayAndAcceptCall -> acceptIncomingCall(it)
RoomDetailViewEvents.RoomReplacementStarted -> handleRoomReplacement() RoomDetailViewEvents.RoomReplacementStarted -> handleRoomReplacement()
RoomDetailViewEvents.ShowLocationSharingIndicator -> handleShowLocationSharingIndicator() is RoomDetailViewEvents.ChangeLocationIndicator -> handleChangeLocationIndicator(it)
RoomDetailViewEvents.HideLocationSharingIndicator -> handleHideLocationSharingIndicator()
} }
} }
@ -618,12 +617,8 @@ class TimelineFragment @Inject constructor(
) )
} }
private fun handleShowLocationSharingIndicator() { private fun handleChangeLocationIndicator(event: RoomDetailViewEvents.ChangeLocationIndicator) {
views.locationLiveStatusIndicator.isVisible = true views.locationLiveStatusIndicator.isVisible = event.isVisible
}
private fun handleHideLocationSharingIndicator() {
views.locationLiveStatusIndicator.isVisible = false
} }
private fun displayErrorMessage(error: RoomDetailViewEvents.Failure) { private fun displayErrorMessage(error: RoomDetailViewEvents.Failure) {

View file

@ -1224,11 +1224,11 @@ class TimelineViewModel @AssistedInject constructor(
} }
override fun onLocationServiceRunning() { override fun onLocationServiceRunning() {
_viewEvents.post(RoomDetailViewEvents.ShowLocationSharingIndicator) _viewEvents.post(RoomDetailViewEvents.ChangeLocationIndicator(isVisible = true))
} }
override fun onLocationServiceStopped() { override fun onLocationServiceStopped() {
_viewEvents.post(RoomDetailViewEvents.HideLocationSharingIndicator) _viewEvents.post(RoomDetailViewEvents.ChangeLocationIndicator(isVisible = false))
// Bind again in case user decides to share live location without leaving the room // Bind again in case user decides to share live location without leaving the room
locationSharingServiceConnection.bind(this) locationSharingServiceConnection.bind(this)
} }