Code review fixes.

This commit is contained in:
Onuray Sahin 2021-09-08 13:44:52 +03:00
parent 1df867f345
commit 3bd392a55d
3 changed files with 6 additions and 6 deletions

View file

@ -36,7 +36,7 @@ data class ContentAttachmentData(
val queryUri: Uri,
val mimeType: String?,
val type: Type,
val waveform: List<Int?>? = null
val waveform: List<Int>? = null
) : Parcelable {
@JsonClass(generateAdapter = false)

View file

@ -185,7 +185,7 @@ internal class DefaultSendService @AssistedInject constructor(
name = messageContent.body,
queryUri = Uri.parse(messageContent.url),
type = ContentAttachmentData.Type.AUDIO,
waveform = messageContent.audioWaveformInfo?.waveform
waveform = messageContent.audioWaveformInfo?.waveform?.filterNotNull()
)
localEchoRepository.updateSendState(localEcho.eventId, roomId, SendState.UNSENT)
internalSendMedia(listOf(localEcho.root), attachmentData, true)

View file

@ -33,7 +33,7 @@ internal class WaveFormSanitizer @Inject constructor() {
* The array should have no less than 30 elements and no more than 120.
* List of integers between zero and 1024, inclusive.
*/
fun sanitize(waveForm: List<Int?>?): List<Int>? {
fun sanitize(waveForm: List<Int>?): List<Int>? {
if (waveForm.isNullOrEmpty()) {
return null
}
@ -46,7 +46,7 @@ internal class WaveFormSanitizer @Inject constructor() {
val repeatTimes = ceil(MIN_NUMBER_OF_VALUES / waveForm.size.toDouble()).toInt()
waveForm.map { value ->
repeat(repeatTimes) {
sizeInRangeList.add(value ?: 0)
sizeInRangeList.add(value)
}
}
}
@ -54,12 +54,12 @@ internal class WaveFormSanitizer @Inject constructor() {
val keepOneOf = ceil(waveForm.size.toDouble() / MAX_NUMBER_OF_VALUES).toInt()
waveForm.mapIndexed { idx, value ->
if (idx % keepOneOf == 0) {
sizeInRangeList.add(value ?: 0)
sizeInRangeList.add(value)
}
}
}
else -> {
sizeInRangeList.addAll(waveForm.filterNotNull())
sizeInRangeList.addAll(waveForm)
}
}