Skip to content

Documentation

Bohdan Semeniuk edited this page Sep 4, 2016 · 3 revisions

Basic usage

1. Fire pick request

Use one of:

QiPick.in(activityLauncher).fromCamera();
QiPick.in(activityLauncher).fromGallery();
QiPick.in(activityLauncher).fromDocuments();
QiPick.in(activityLauncher).fromMultipleSources("All sources", PickSource.CAMERA, PickSource.DOCUMENTS);
QiPick.in(activityLauncher).fromMultipleSources(R.string.chooser_title, PickSource.CAMERA, PickSource.GALLERY);

activityLauncher may be an Activity, Fragment or a support Fragment.

All of these methods return a trigger result int which defines whether pick request was fired successfully. If not, it can be used as error code (codes listed in PickTriggerResult)

2. Handle result in onActivityResult of Activity or Fragment (activityLauncher from step 1):

private final PickCallback mCallback = new PickCallback() {

    @Override
    public void onImagePicked(@NonNull final PickSource pPickSource, final int pRequestType, @NonNull final Uri pImageUri) {
        // Do something with Uri, for example load image into an ImageView
        Glide.with(getApplicationContext())
             .load(pImageUri)
             .fitCenter()
             .into(mImageView);
    }

    @Override
    public void onError(@NonNull final PickSource pPickSource, final int pRequestType, @NonNull final String pErrorString) {
        Log.e(TAG, "Err: " + pErrorString);
    }

    @Override
    public void onCancel(@NonNull final PickSource pPickSource, final int pRequestType) {
        Log.d(TAG, "Cancel: " + pPickSource.name());
    }

};

@Override
protected void onActivityResult(final int pRequestCode, final int pResultCode, final Intent pData) {
super.onActivityResult(pRequestCode, pResultCode, pData);
    super.onActivityResult(pRequestCode, pResultCode, pData);
    
    QiPick.handleActivityResult(getApplicationContext(), pRequestCode, pResultCode, pData, this.mCallback);
            
}

That's it!

Now, proceed to Advanced usage to customize pick flow setup

Clone this wiki locally