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 RoomReplacementStarted : RoomDetailViewEvents()
object ShowLocationSharingIndicator : RoomDetailViewEvents()
object HideLocationSharingIndicator : RoomDetailViewEvents()
data class ChangeLocationIndicator(val isVisible: Boolean) : RoomDetailViewEvents()
}

View file

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

View file

@ -1224,11 +1224,11 @@ class TimelineViewModel @AssistedInject constructor(
}
override fun onLocationServiceRunning() {
_viewEvents.post(RoomDetailViewEvents.ShowLocationSharingIndicator)
_viewEvents.post(RoomDetailViewEvents.ChangeLocationIndicator(isVisible = true))
}
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
locationSharingServiceConnection.bind(this)
}