Fix kotling warnings for Image.kt and Folder.kt (part of Issue #5996) (#6441)
Some checks are pending
Android CI / Run tests and generate APK (push) Waiting to run

* added hash code to folder.kt and image.kt to pair with equals

* fixed deprecation in readParcelable function

---------

Co-authored-by: Nicolas Raoul <nicolas.raoul@gmail.com>
This commit is contained in:
Ben 2025-10-05 09:15:39 -04:00 committed by GitHub
parent ed7007fc8c
commit 6bc25ccd9b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 1 deletions

View file

@ -39,4 +39,11 @@ data class Folder(
return true
}
override fun hashCode(): Int {
var result = bucketId.hashCode()
result = 31 * result + name.hashCode()
result = 31 * result + images.hashCode()
return result
}
}

View file

@ -1,6 +1,7 @@
package fr.free.nrw.commons.customselector.model
import android.net.Uri
import android.os.Build
import android.os.Parcel
import android.os.Parcelable
@ -48,7 +49,12 @@ data class Image(
this(
parcel.readLong(),
parcel.readString()!!,
parcel.readParcelable(Uri::class.java.classLoader)!!,
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
parcel.readParcelable(Uri::class.java.classLoader, Uri::class.java)!!
} else {
@Suppress("DEPRECATION")
parcel.readParcelable(Uri::class.java.classLoader)!!
},
parcel.readString()!!,
parcel.readLong(),
parcel.readString()!!,
@ -121,4 +127,16 @@ data class Image(
override fun newArray(size: Int): Array<Image?> = arrayOfNulls(size)
}
override fun hashCode(): Int {
var result = id.hashCode()
result = 31 * result + bucketId.hashCode()
result = 31 * result + name.hashCode()
result = 31 * result + uri.hashCode()
result = 31 * result + path.hashCode()
result = 31 * result + bucketName.hashCode()
result = 31 * result + sha1.hashCode()
result = 31 * result + date.hashCode()
return result
}
}