Table of Contents
New Android variations support
Receiving begun
Increase dependency
implementation 'ro.dragossusi.android:imagepicker:1..'
Declare your focus on directory
You can declare your goal directory employing code or string useful resource.
For code, initialise the ImagePicker listing(usually in Software class):
ImagePicker.listing = "YourDirectory"
For String resource:
<string name="image_picker_folder_name">YourDirectorystring>
Make the ImageWrapper
The library arrives with a wrapper for fragments:
private val imagePickWrapper = FragmentImagePickerWrapper(
this,
"$BuildConfig.Application_ID.filesystem.provider",
::onPermissionError
) uri:Uri?->
//todo what you want with the image
non-public exciting onPermissionError(permission: String)
//todo permission mistake dealing with
AlertDialog.Builder(requireContext())
.setTitle("Your authorization error")
.setMessage(permission)
.present()
Use builtin AvatarImageView
Include the AvatarImageView in the layout xml
<ro.dragossusi.android.imagepicker.ui.AvatarImageView
android:id="@+id/image_avatar"
android:layout_width="120dp"
android:layout_height="120dp"
android:background="?selectableItemBackgroundBorderless"
android:clickable="true"
android:focusable="true"
tools:src="@tools:sample/avatars" />
Established the wrapper to the see
override exciting onViewCreated(view: View, savedInstanceState: Bundle?)
super.onViewCreated(watch, savedInstanceState)
//auto sets onClickListener
findViewById<AvatarImageView>(R.id.picture_avatar)
.imagePickerWrapper = imagePickWrapper