RxImagePicker

Additional

Language
Java
Version
N/A
Created
Dec 12, 2015
Updated
Dec 25, 2017
Owner
MLSDev
Contributors
hamen
Saad Farooq (saadfarooq)
Alex Isaienko (s0nerik)
Zabelnikov Sergey (ReginFell)
Tim Malseed (timusus)
Frederikos
weverb2
stuartsoft
8
Activity
Badge
Generate
Download
Source code
APK file

Advertising

RxImagePicker

An easy way to get image from Gallery or Camera with request runtime permission on Android M using RxJava2

Setup

To use this library your minSdkVersion must be >= 16.

In your build.gradle :

dependencies {
    compile 'com.mlsdev.rximagepicker:library:2.0.2'    
}

Example

RxImagePicker.with(context).requestImage(Sources.CAMERA).subscribe(new Consumer<Uri>() {
                    @Override
                    public void accept(@NonNull Uri uri) throws Exception {
                        //Get image by uri using one of image loading libraries. I use Glide in sample app.
                    }
                });

Request multiple images on Android Api level 18+ :

RxImagePicker.with(getContext()).requestMultipleImages().subscribe(new Consumer<List<Uri>>() {
                    @Override
                    public void accept(@NonNull List<Uri> uris) throws Exception {
                        //Get images by uris.
                    }
                });

Using converters

RxImagePicker.with(context).requestImage(Sources.GALLERY)
    .flatMap(new Function<Uri, ObservableSource<Bitmap>>() {
                    @Override
                    public ObservableSource<Bitmap> apply(@NonNull Uri uri) throws Exception {
                        return RxImageConverters.uriToBitmap(getContext(), uri);
                    }
                }).subscribe(new Consumer<Bitmap>() {
                    @Override
                    public void accept(@NonNull Bitmap bitmap) throws Exception {
                        // Do something with Bitmap
                    }
                });
RxImagePicker.with(context).requestImage(Sources.GALLERY)
    .flatMap(new Function<Uri, ObservableSource<File>>() {
                    @Override
                    public ObservableSource<File> apply(@NonNull Uri uri) throws Exception {
                        return RxImageConverters.uriToFile(getContext(), uri, new File("YOUR FILE"));
                    }
                }).subscribe(new Consumer<File>() {
                    @Override
                    public void accept(@NonNull File file) throws Exception {
                        // Do something with your file copy
                    }
                });

Sample App

Authors

License

RxImagePicker is released under the MIT license. See LICENSE for details.

About MLSDev

RxImagePicker is maintained by MLSDev, Inc. We specialize in providing all-in-one solution in mobile and web development. Our team follows Lean principles and works according to agile methodologies to deliver the best results reducing the budget for development and its timeline.

Find out more here and don't hesitate to contact us!