MultiImageSelector

Additional

Language
Java
Version
1.2 (Jun 12, 2016)
Created
Apr 8, 2015
Updated
Jun 1, 2018
Owner
Nereo (lovetuzitong)
Contributors
Nereo (lovetuzitong)
sleepingAnt
2
Activity
Badge
Generate
Download
Source code
APK file

Commercial

MultiImageSelector

Image selector for Android device. Support single choice and multi-choice.

中文文档

###ART

###Run Demo

./gradlew installDebug

###Quick Start

  • Step 0 Add module
    multi-image-selector as your dependence. in your build.gradle :repositories { maven { url "https://jitpack.io" } } dependencies { compile 'com.github.lovetuzitong:MultiImageSelector:1.2' }


  • Step 1 Set your AndroidManifest.xml as below:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application

    ...

    <!--Image Selector Entry-->
    <activity
        android:configChanges="orientation|screenSize"
        android:name="me.nereo.multi_image_selector.MultiImageSelectorActivity" />
</application>
  • Step 2 Call image selector simplest in your code, eg. ( From version-1.1 )
// Multi image selector form an Activity
MultiImageSelector.create(Context)
        .start(Activity, REQUEST_IMAGE);

Detail Api.

MultiImageSelector.create(Context)
        .showCamera(boolean) // show camera or not. true by default
        .count(int) // max select image size, 9 by default. used width #.multi()
        .single() // single mode
        .multi() // multi mode, default mode;
        .origin(ArrayList<String>) // original select data set, used width #.multi()
        .start(Activity/Fragment, REQUEST_IMAGE);

Also support traditional Intent :

Intent intent = new Intent(mContext, MultiImageSelectorActivity.class);
// whether show camera
intent.putExtra(MultiImageSelectorActivity.EXTRA_SHOW_CAMERA, true);
// max select image amount
intent.putExtra(MultiImageSelectorActivity.EXTRA_SELECT_COUNT, 9);
// select mode (MultiImageSelectorActivity.MODE_SINGLE OR MultiImageSelectorActivity.MODE_MULTI)
intent.putExtra(MultiImageSelectorActivity.EXTRA_SELECT_MODE, MultiImageSelectorActivity.MODE_MULTI);
// default select images (support array list)
intent.putStringArrayListExtra(MultiImageSelectorActivity.EXTRA_DEFAULT_SELECTED_LIST, defaultDataArray);
startActivityForResult(intent, REQUEST_IMAGE);
  • Step 3 Receive result in your onActivityResult Method. eg.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if(requestCode == REQUEST_IMAGE){
        if(resultCode == RESULT_OK){
         // Get the result list of select image paths
            List<String> path = data.getStringArrayListExtra(MultiImageSelectorActivity.EXTRA_RESULT);
            // do your logic ....
        }
    }
}
  • Step 4 No more steps, just enjoy. :)

###Custom Activity Style