Skip to content

Commit

Permalink
Update docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrtwhite committed Feb 6, 2020
1 parent 8c8d1fa commit 14433b5
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 22 deletions.
7 changes: 3 additions & 4 deletions coil-gif/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@ implementation("io.coil-kt:coil-gif:0.9.4")
And add the decoders to your component registry when constructing your `ImageLoader`:

```kotlin
val imageLoader = ImageLoader(context) {
componentRegistry {
val imageLoader = ImageLoader.Builder(context)
.componentRegistry {
if (SDK_INT >= P) {
add(ImageDecoderDecoder())
} else {
add(GifDecoder())
}
}
}
.build()
```

And that's it! The `ImageLoader` will automatically detect any GIFs using their file headers and decode them correctly.

!!! Note
Coil includes two separate decoders to support decoding GIFs. `GifDecoder` supports all API levels, but is slower. `ImageDecoderDecoder` is powered by Android's new [ImageDecoder](https://developer.android.com/reference/android/graphics/ImageDecoder) API which is only available on Android P and above. `ImageDecoderDecoder` is faster than `GifDecoder` and also supports decoding animated WebP images.

6 changes: 3 additions & 3 deletions coil-svg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ implementation("io.coil-kt:coil-svg:0.9.4")
And add the decoder to your component registry when constructing your `ImageLoader`:

```kotlin
val imageLoader = ImageLoader(context) {
componentRegistry {
val imageLoader = ImageLoader.Builder(context)
.componentRegistry {
add(SvgDecoder())
}
}
.build()
```

And that's it! The `ImageLoader` will automatically detect any SVGs using their file headers and decode them correctly.
8 changes: 4 additions & 4 deletions docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ If you're using the `io.coil-kt:coil` artifact, you can set a default [ImageLoad

```kotlin
Coil.setDefaultImageLoader {
ImageLoader(context) {
crossfade(true)
okHttpClient {
ImageLoader.Builder(context)
.crossfade(true)
.okHttpClient {
OkHttpClient.Builder()
.cache(CoilUtils.createDefaultCache(context))
.build()
}
}
.build()
}
```

Expand Down
16 changes: 8 additions & 8 deletions docs/image_loaders.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ val imageLoader = ImageLoader(context)
Similar to [Requests](requests.md), `ImageLoader`s can be configured with an optional trailing lambda param:

```kotlin
val imageLoader = ImageLoader(context) {
availableMemoryPercentage(0.5)
bitmapPoolPercentage(0.5)
crossfade(true)
}
val imageLoader = ImageLoader.Builder(context)
.availableMemoryPercentage(0.5)
.bitmapPoolPercentage(0.5)
.crossfade(true)
.build()
```

Internally, this constructs a `RealImageLoader` using [ImageLoaderBuilder](../api/coil-base/coil/-image-loader-builder).
Expand All @@ -31,13 +31,13 @@ Coil relies on `OkHttpClient` to handle disk caching. **By default, every `Image
However, if you set a custom `OkHttpClient`, you'll need to add the disk cache yourself. To get a `Cache` instance that's optimized for Coil, you can use [`CoilUtils.createDefaultCache`](../api/coil-base/coil.util/-coil-utils/create-default-cache/). Optionally, you can create your own `Cache` instance with a different size + location. Here's an example:

```kotlin
val imageLoader = ImageLoader(context) {
okHttpClient {
val imageLoader = ImageLoader.Builder(context)
.okHttpClient {
OkHttpClient.Builder()
.cache(CoilUtils.createDefaultCache(context))
.build()
}
}
.build()
```

## Singleton vs. Dependency Injection
Expand Down
6 changes: 3 additions & 3 deletions docs/image_pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ Fortunately, [ImageLoaders](image_loaders.md) support pluggable components to ad
Custom components must be added to the `ImageLoader` when constructing it through its [ComponentRegistry](../api/coil-base/coil/-component-registry):

```kotlin
val imageLoader = ImageLoader(context) {
componentRegistry {
val imageLoader = ImageLoader.Builder(context)
.componentRegistry {
add(ItemMapper())
add(ProtocolBufferFetcher())
add(GifDecoder())
}
}
.build()
```

## Mappers
Expand Down

0 comments on commit 14433b5

Please sign in to comment.