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

This commit is contained in:
Benoit Marty
2023-11-03 17:32:38 +01:00
parent 0608f1ff81
commit b907b77733

View File

@@ -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