File tree Expand file tree Collapse file tree
picasso/src/main/java/com/squareup/picasso3 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ buildscript {
2020 mockWebServer : " com.squareup.okhttp3:mockwebserver:${ versions.okhttp} " ,
2121 pollexor : ' com.squareup:pollexor:3.0.0' ,
2222 androidxAnnotations : ' androidx.annotation:annotation:1.3.0' ,
23- androidxCore : ' androidx.core:core:1.6.0' ,
23+ androidxCore : ' androidx.core:core-ktx :1.6.0' ,
2424 androidxCursorAdapter : ' androidx.cursoradapter:cursoradapter:1.0.0' ,
2525 androidxExifInterface : ' androidx.exifinterface:exifinterface:1.3.3' ,
2626 androidxFragment : ' androidx.fragment:fragment:1.4.0' ,
Original file line number Diff line number Diff line change 1616package com.squareup.picasso3
1717
1818import android.graphics.Bitmap
19- import android.util.LruCache
2019import androidx.core.graphics.BitmapCompat
20+ import androidx.core.util.lruCache
2121
2222/* * A memory cache which uses a least-recently used eviction policy. */
2323internal class PlatformLruCache (maxByteCount : Int ) {
24-
2524 /* * Create a cache with a given maximum size in bytes. */
26- val cache =
27- object : LruCache <String , BitmapAndSize >(if (maxByteCount != 0 ) maxByteCount else 1 ) {
28- override fun sizeOf (
29- key : String ,
30- value : BitmapAndSize
31- ): Int = value.byteCount
32- }
25+ val cache = lruCache<String , BitmapAndSize >(
26+ maxByteCount.coerceAtLeast(1 ),
27+ sizeOf = { _, value -> value.byteCount }
28+ )
3329
3430 operator fun get (key : String ): Bitmap ? = cache[key]?.bitmap
3531
You can’t perform that action at this time.
0 commit comments