-
Notifications
You must be signed in to change notification settings - Fork 665
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set memory cache extras for transformations when calling ImageRequest…
….Builder.transformations.
- Loading branch information
1 parent
f5cc579
commit 46f18c5
Showing
6 changed files
with
25 additions
and
40 deletions.
There are no files selected for viewing
20 changes: 2 additions & 18 deletions
20
coil-core/src/androidMain/kotlin/coil3/memory/MemoryCacheService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,8 @@ | ||
package coil3.memory | ||
|
||
import coil3.memory.MemoryCacheService.Companion.EXTRA_TRANSFORMATION_INDEX | ||
import coil3.memory.MemoryCacheService.Companion.EXTRA_TRANSFORMATION_SIZE | ||
import coil3.request.ImageRequest | ||
import coil3.request.Options | ||
import coil3.request.transformations | ||
import coil3.util.forEachIndexedIndices | ||
|
||
internal actual fun createComplexMemoryCacheKeyExtras( | ||
request: ImageRequest, | ||
options: Options, | ||
): Map<String, String> { | ||
var memoryCacheKeyExtras = request.memoryCacheKeyExtras | ||
if (request.transformations.isNotEmpty()) { | ||
val mutableMemoryCacheKeyExtras = memoryCacheKeyExtras.toMutableMap() | ||
request.transformations.forEachIndexedIndices { index, transformation -> | ||
mutableMemoryCacheKeyExtras[EXTRA_TRANSFORMATION_INDEX + index] = transformation.cacheKey | ||
} | ||
mutableMemoryCacheKeyExtras[EXTRA_TRANSFORMATION_SIZE] = options.size.toString() | ||
memoryCacheKeyExtras = mutableMemoryCacheKeyExtras | ||
} | ||
return memoryCacheKeyExtras | ||
internal actual fun ImageRequest.needsSizeInCacheKey(): Boolean { | ||
return transformations.isNotEmpty() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 1 addition & 7 deletions
8
coil-core/src/nonAndroidMain/kotlin/coil3/memory/MemoryCacheService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,5 @@ | ||
package coil3.memory | ||
|
||
import coil3.request.ImageRequest | ||
import coil3.request.Options | ||
|
||
internal actual fun createComplexMemoryCacheKeyExtras( | ||
request: ImageRequest, | ||
options: Options, | ||
): Map<String, String> { | ||
return request.memoryCacheKeyExtras | ||
} | ||
internal actual fun ImageRequest.needsSizeInCacheKey() = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters