diff --git a/coil-base/api/coil-base.api b/coil-base/api/coil-base.api index a43a5e704e..9fc971dca9 100644 --- a/coil-base/api/coil-base.api +++ b/coil-base/api/coil-base.api @@ -242,7 +242,7 @@ public abstract interface class coil/disk/DiskCache { } public final class coil/disk/DiskCache$Builder { - public fun (Landroid/content/Context;)V + public fun ()V public final fun build ()Lcoil/disk/DiskCache; public final fun cleanupDispatcher (Lkotlinx/coroutines/CoroutineDispatcher;)Lcoil/disk/DiskCache$Builder; public final fun directory (Ljava/io/File;)Lcoil/disk/DiskCache$Builder; diff --git a/coil-base/src/main/java/coil/disk/DiskCache.kt b/coil-base/src/main/java/coil/disk/DiskCache.kt index 37a0df9437..768a278b0c 100644 --- a/coil-base/src/main/java/coil/disk/DiskCache.kt +++ b/coil-base/src/main/java/coil/disk/DiskCache.kt @@ -2,7 +2,6 @@ package coil.disk -import android.content.Context import android.os.StatFs import androidx.annotation.FloatRange import coil.annotation.ExperimentalCoilApi @@ -101,7 +100,7 @@ interface DiskCache { fun abort() } - class Builder(private val context: Context) { + class Builder { private var directory: File? = null private var maxSizePercent = 0.02 // 2% diff --git a/coil-base/src/main/java/coil/util/Utils.kt b/coil-base/src/main/java/coil/util/Utils.kt index a057c6b46c..8211e8c910 100644 --- a/coil-base/src/main/java/coil/util/Utils.kt +++ b/coil-base/src/main/java/coil/util/Utils.kt @@ -259,7 +259,7 @@ internal object SingletonDiskCache { fun get(context: Context): DiskCache { return instance ?: run { // Create the singleton disk cache instance. - DiskCache.Builder(context) + DiskCache.Builder() .directory(context.safeCacheDir.resolve(FOLDER_NAME)) .build() .also { instance = it } diff --git a/coil-base/src/test/java/coil/disk/DiskCacheTest.kt b/coil-base/src/test/java/coil/disk/DiskCacheTest.kt index c03c1983af..e066ae4018 100644 --- a/coil-base/src/test/java/coil/disk/DiskCacheTest.kt +++ b/coil-base/src/test/java/coil/disk/DiskCacheTest.kt @@ -1,7 +1,5 @@ package coil.disk -import android.content.Context -import androidx.test.core.app.ApplicationProvider import okio.buffer import okio.sink import okio.source @@ -19,13 +17,11 @@ import kotlin.test.assertTrue @RunWith(RobolectricTestRunner::class) class DiskCacheTest { - private lateinit var context: Context private lateinit var diskCache: DiskCache @Before fun before() { - context = ApplicationProvider.getApplicationContext() - diskCache = DiskCache.Builder(context).directory(File("build/cache")).build() + diskCache = DiskCache.Builder().directory(File("build/cache")).build() } @After diff --git a/coil-base/src/test/java/coil/fetch/HttpUriFetcherTest.kt b/coil-base/src/test/java/coil/fetch/HttpUriFetcherTest.kt index 6c305df132..c8ff96938e 100644 --- a/coil-base/src/test/java/coil/fetch/HttpUriFetcherTest.kt +++ b/coil-base/src/test/java/coil/fetch/HttpUriFetcherTest.kt @@ -58,7 +58,7 @@ class HttpUriFetcherTest { fun before() { context = ApplicationProvider.getApplicationContext() server = createMockWebServer() - diskCache = DiskCache.Builder(context) + diskCache = DiskCache.Builder() .directory(File("build/cache")) .maxSizeBytes(10L * 1024 * 1024) // 10MB .build() diff --git a/coil-sample-common/src/main/java/coil/sample/Application.kt b/coil-sample-common/src/main/java/coil/sample/Application.kt index b8f30edc4f..a969921da6 100644 --- a/coil-sample-common/src/main/java/coil/sample/Application.kt +++ b/coil-sample-common/src/main/java/coil/sample/Application.kt @@ -41,7 +41,7 @@ class Application : Application(), ImageLoaderFactory { .build() } .diskCache { - DiskCache.Builder(this) + DiskCache.Builder() .directory(filesDir.resolve("image_cache")) .maxSizeBytes(512L * 1024 * 1024) // 512MB .build()