Code review fixes.

This commit is contained in:
Onuray Sahin 2022-03-07 15:52:19 +03:00
parent 2c611790db
commit 3156410965
4 changed files with 3 additions and 2 deletions

View File

@ -83,7 +83,7 @@ class VoiceMessageViews(
observeMicButton(actions)
}
private fun getTouchedPositionPercentage(motionEvent: MotionEvent, view: View) = motionEvent.x / view.width
private fun getTouchedPositionPercentage(motionEvent: MotionEvent, view: View) = (motionEvent.x / view.width).coerceIn(0f, 1f)
@SuppressLint("ClickableViewAccessibility")
private fun observeMicButton(actions: Actions) {

View File

@ -709,6 +709,7 @@ class MessageItemFactory @Inject constructor(
return this
?.filterNotNull()
?.map {
// Value comes from AudioWaveformView.MAX_FFT, and 1024 is the max value in the Matrix spec
it * AudioWaveformView.MAX_FFT / 1024
}
}

View File

@ -134,7 +134,7 @@ abstract class MessageVoiceItem : AbsMessageItem<MessageVoiceItem.Holder>() {
}
}
private fun getTouchedPositionPercentage(motionEvent: MotionEvent, view: View) = motionEvent.x / view.width
private fun getTouchedPositionPercentage(motionEvent: MotionEvent, view: View) = (motionEvent.x / view.width).coerceIn(0f, 1f)
private fun renderIdleState(holder: Holder, idleColor: Int, playedColor: Int) {
holder.voicePlaybackControlButton.setImageResource(R.drawable.ic_play_pause_play)