Skip to content

Commit

Permalink
update custom_components.md to use Kotlin and reflect current API (#…
Browse files Browse the repository at this point in the history
…424)

* update `custom_components.md` to reflect current API

* add explanation about creating custom ImagePickerComponents
  • Loading branch information
wiryadev authored Nov 19, 2022
1 parent 514f7ed commit 5ff7914
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions docs/custom_components.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
# Custom Components

You also can change how to process the image and how to get the image files through `ImageLoader` and `ImageFileLoader`
To change this, simply set it on `ImagePickerComponentHolder`
To change this, first, create custom `ImagePickerComponents`.
You could inherit from `DefaultImagePickerComponents` or directly implements from `ImagePickerComponents` interface.

```java
ImagePickerComponentHolder.getInstance()
.setImageLoader(new GrayScaleImageLoader())
.setImageFileLoader(new WebpImageFileLoader())
```
```kotlin
class CustomImagePickerComponents(
context: Context
) : DefaultImagePickerComponents(context.applicationContext) {
override val imageLoader: ImageLoader
get() = GrayscaleImageLoader()
}
```

Happy coding!
Then, use it by calling `setInternalComponent` on `ImagePickerComponentsHolder`.
```kotlin
ImagePickerComponentsHolder.setInternalComponent(
CustomImagePickerComponents(context)
)
```

Happy coding!

0 comments on commit 5ff7914

Please sign in to comment.