mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-26 19:36:08 +03:00
separating the cancelled and ended events to make the consumption simpler
This commit is contained in:
parent
4dbb150ac2
commit
1afc1b51e5
2 changed files with 19 additions and 14 deletions
|
@ -708,18 +708,12 @@ class RoomDetailFragment @Inject constructor(
|
|||
roomDetailViewModel.handle(RoomDetailAction.PlayOrPauseRecordingPlayback)
|
||||
}
|
||||
|
||||
override fun onVoiceRecordingEnded(lastKnownState: RecordingUiState?) {
|
||||
when (lastKnownState) {
|
||||
RecordingUiState.Locked -> {
|
||||
// do nothing,
|
||||
// onSendVoiceMessage, onDeleteVoiceMessage or onRecordingLimitReached will be triggered instead
|
||||
}
|
||||
else -> {
|
||||
val isCancelled = lastKnownState == RecordingUiState.Cancelled
|
||||
roomDetailViewModel.handle(RoomDetailAction.EndRecordingVoiceMessage(isCancelled = isCancelled))
|
||||
updateRecordingUiState(RecordingUiState.None)
|
||||
}
|
||||
}
|
||||
override fun onVoiceRecordingCancelled() {
|
||||
onDeleteVoiceMessage()
|
||||
}
|
||||
|
||||
override fun onVoiceRecordingEnded() {
|
||||
onSendVoiceMessage()
|
||||
}
|
||||
|
||||
override fun onUiStateChanged(state: RecordingUiState) {
|
||||
|
|
|
@ -41,8 +41,9 @@ class VoiceMessageRecorderView @JvmOverloads constructor(
|
|||
|
||||
interface Callback {
|
||||
fun onVoiceRecordingStarted()
|
||||
fun onVoiceRecordingEnded(lastKnownState: RecordingUiState?)
|
||||
fun onVoiceRecordingEnded()
|
||||
fun onVoicePlaybackButtonClicked()
|
||||
fun onVoiceRecordingCancelled()
|
||||
fun onUiStateChanged(state: RecordingUiState)
|
||||
fun onSendVoiceMessage()
|
||||
fun onDeleteVoiceMessage()
|
||||
|
@ -72,7 +73,17 @@ class VoiceMessageRecorderView @JvmOverloads constructor(
|
|||
private fun initListeners() {
|
||||
voiceMessageViews.start(object : VoiceMessageViews.Actions {
|
||||
override fun onRequestRecording() = callback.onVoiceRecordingStarted()
|
||||
override fun onMicButtonReleased() = callback.onVoiceRecordingEnded(lastKnownState)
|
||||
override fun onMicButtonReleased() {
|
||||
when (lastKnownState) {
|
||||
RecordingUiState.Locked -> {
|
||||
// do nothing,
|
||||
// onSendVoiceMessage, onDeleteVoiceMessage or onRecordingLimitReached will be triggered instead
|
||||
}
|
||||
RecordingUiState.Cancelled -> callback.onVoiceRecordingCancelled()
|
||||
else -> callback.onVoiceRecordingEnded()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSendVoiceMessage() = callback.onSendVoiceMessage()
|
||||
override fun onDeleteVoiceMessage() = callback.onDeleteVoiceMessage()
|
||||
override fun onWaveformClicked() = callback.onRecordingWaveformClicked()
|
||||
|
|
Loading…
Reference in a new issue