Browse Source

Convert Data.Audio to data class, and implement equals and hashCode as suggested.

pull/1731/head
Benoit Marty 11 months ago
parent
commit
6fda11aff0
  1. 22
      libraries/voicerecorder/impl/src/main/kotlin/io/element/android/libraries/voicerecorder/impl/audio/Audio.kt

22
libraries/voicerecorder/impl/src/main/kotlin/io/element/android/libraries/voicerecorder/impl/audio/Audio.kt

@ -17,10 +17,28 @@ @@ -17,10 +17,28 @@
package io.element.android.libraries.voicerecorder.impl.audio
sealed interface Audio {
class Data(
data class Data(
val readSize: Int,
val buffer: ShortArray,
) : Audio
) : Audio {
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as Data
if (readSize != other.readSize) return false
if (!buffer.contentEquals(other.buffer)) return false
return true
}
override fun hashCode(): Int {
var result = readSize
result = 31 * result + buffer.contentHashCode()
return result
}
}
data class Error(
val audioRecordErrorCode: Int

Loading…
Cancel
Save