Skip to content

Commit

Permalink
Add more params to DefaultModelEqualityDelegate. (#2140)
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrtwhite committed Feb 22, 2024
1 parent 6e1c390 commit 5460933
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions coil-compose-base/src/main/java/coil/compose/EqualityDelegate.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,34 @@ interface EqualityDelegate {
val DefaultModelEqualityDelegate = object : EqualityDelegate {

override fun equals(self: Any?, other: Any?): Boolean {
if (self === other) {
return true
}

if (self !is ImageRequest || other !is ImageRequest) {
return self == other
}

return self.context == other.context &&
self.data == other.data &&
self.placeholderMemoryCacheKey == other.placeholderMemoryCacheKey &&
self.memoryCacheKey == other.memoryCacheKey &&
self.parameters == other.parameters &&
self.diskCacheKey == other.diskCacheKey &&
self.bitmapConfig == other.bitmapConfig &&
self.colorSpace == other.colorSpace &&
self.transformations == other.transformations &&
self.headers == other.headers &&
self.allowConversionToBitmap == other.allowConversionToBitmap &&
self.allowHardware == other.allowHardware &&
self.allowRgb565 == other.allowRgb565 &&
self.premultipliedAlpha == other.premultipliedAlpha &&
self.memoryCachePolicy == other.memoryCachePolicy &&
self.diskCachePolicy == other.diskCachePolicy &&
self.networkCachePolicy == other.networkCachePolicy &&
self.sizeResolver == other.sizeResolver &&
self.scale == other.scale &&
self.precision == other.precision
self.precision == other.precision &&
self.parameters == other.parameters
}

override fun hashCode(self: Any?): Int {
Expand All @@ -40,12 +56,24 @@ val DefaultModelEqualityDelegate = object : EqualityDelegate {

var result = self.context.hashCode()
result = 31 * result + self.data.hashCode()
result = 31 * result + self.placeholderMemoryCacheKey.hashCode()
result = 31 * result + self.memoryCacheKey.hashCode()
result = 31 * result + self.parameters.hashCode()
result = 31 * result + self.diskCacheKey.hashCode()
result = 31 * result + self.bitmapConfig.hashCode()
result = 31 * result + self.colorSpace.hashCode()
result = 31 * result + self.transformations.hashCode()
result = 31 * result + self.headers.hashCode()
result = 31 * result + self.allowConversionToBitmap.hashCode()
result = 31 * result + self.allowHardware.hashCode()
result = 31 * result + self.allowRgb565.hashCode()
result = 31 * result + self.premultipliedAlpha.hashCode()
result = 31 * result + self.memoryCachePolicy.hashCode()
result = 31 * result + self.diskCachePolicy.hashCode()
result = 31 * result + self.networkCachePolicy.hashCode()
result = 31 * result + self.sizeResolver.hashCode()
result = 31 * result + self.scale.hashCode()
result = 31 * result + self.precision.hashCode()
result = 31 * result + self.parameters.hashCode()
return result
}
}

0 comments on commit 5460933

Please sign in to comment.