Android image selector, rich configuration options, greatly simplified use

Recently, it happened to be used in the project, so I wrote a library of Android image selectors. Support gallery multi-selection/single selection/image cropping/photography/custom image loading library, which greatly simplifies the use.

Screenshot


Advantages

1. By implementing the ImageLoader interface, you can implement the function of a custom image loader. For example, Glide, Picasso, and ImageLoader can be used. Fresco is not supported because SimpleDraweeView itself does not belong to ImageView. Of course, the same idea can also be used to achieve.
2. Configurable ImgSelConfig. Easy to expand.
3. Simplified use

Project address

https://github.com/smuyyh/ImageSelector

dependency
dependencies {
    compile 'com.yuyh.imgsel:library:1.0.1'
}

Use

configure permissions
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />

use
// custom image loader
private ImageLoader loader = new ImageLoader() {
    @Override
    public void displayImage(Context context, String path, ImageView imageView) {
        // TODO here you can customize the image loading library to load ImageView, such as Glide, Picasso, ImageLoader, etc.
        Glide.with(context).load(path).into(imageView);
    }
};
// configuration options
ImgSelConfig config = new ImgSelConfig.Builder(loader)
        // Whether to select multiple
        .multiSelect(false)
        // "OK" button background color
        .btnBgColor(Color.GRAY)
        // "OK" button text color
        .btnTextColor(Color.BLUE)
        // title
        .title("image")
        // title text color
        .titleColor(Color.WHITE)
        // TitleBar background color
        .titleBgColor(Color.parseColor("#3F51B5"))
        // Crop size. Configured when needCrop is true
        .cropSize(1, 1, 200, 200)
        .needCrop(true)
        // Whether the first one shows the camera
        .needCamera(false)
        // maximum number of selected images
        .maxNum(9)
        .build();

// jump to image selector
ImgSelActivity.startActivity(this, config, REQUEST_CODE);

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    // Image selection result callback
    if (requestCode == REQUEST_CODE && resultCode == RESULT_OK && data != null) {
        List<String> pathList = data.getStringArrayListExtra(ImgSelActivity.INTENT_RESULT);
        for (String path : pathList) {
            tvResult.append(path + "\n");
        }
    }
}

Welcome to exchange and correct~

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326618057&siteId=291194637