The Android Arsenal – Picture Pickers

[ad_1]

New Android variations assist

Getting began

Add dependency

    implementation 'ro.dragossusi.android:imagepicker:1.0.0'

Declare your goal listing

You may declare your goal listing utilizing code or string useful resource.

For code, initialise the ImagePicker listing(often in Software class):

ImagePicker.listing = "YourDirectory"

For String useful resource:

<string identify="image_picker_folder_name">YourDirectory</string>

Create the ImageWrapper

The library comes with a wrapper for fragments:

    non-public val imagePickWrapper = FragmentImagePickerWrapper(
        this,
        "${BuildConfig.APPLICATION_ID}.filesystem.supplier",
        ::onPermissionError
    ) { uri:Uri?->
        //todo what you need with the picture
    }

    non-public enjoyable onPermissionError(permission: String) {
        //todo permission error dealing with
        AlertDialog.Builder(requireContext())
            .setTitle("Your permission error")
            .setMessage(permission)
            .present()
    }

Use builtin AvatarImageView

Add the AvatarImageView within the format 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"
    instruments:src="@instruments:pattern/avatars" />

Set the wrapper to the view

    override enjoyable onViewCreated(view: View, savedInstanceState: Bundle?) {
        tremendous.onViewCreated(view, savedInstanceState)
        //auto units onClickListener
        findViewById<AvatarImageView>(R.id.image_avatar)
            .imagePickerWrapper = imagePickWrapper
    }

[ad_2]

Source_link

Leave a Reply

Your email address will not be published.