Convert Data.Audio to data class, and implement equals and hashCode as suggested.
This commit is contained in:
parent
0608f1ff81
commit
b907b77733
1 changed files with 20 additions and 2 deletions
|
|
@ -17,10 +17,28 @@
|
||||||
package io.element.android.libraries.voicerecorder.impl.audio
|
package io.element.android.libraries.voicerecorder.impl.audio
|
||||||
|
|
||||||
sealed interface Audio {
|
sealed interface Audio {
|
||||||
class Data(
|
data class Data(
|
||||||
val readSize: Int,
|
val readSize: Int,
|
||||||
val buffer: ShortArray,
|
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(
|
data class Error(
|
||||||
val audioRecordErrorCode: Int
|
val audioRecordErrorCode: Int
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue