-
Notifications
You must be signed in to change notification settings - Fork 327
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update
custom_components.md
to use Kotlin and reflect current API (#…
…424) * update `custom_components.md` to reflect current API * add explanation about creating custom ImagePickerComponents
- Loading branch information
Showing
1 changed file
with
18 additions
and
7 deletions.
There are no files selected for viewing
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,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! |