The open source address of this project: github.com/yanzhenjie/…

  1. Album is an Android open source Album, which supports single/multiple selection, zooming, preview and view pictures by folder. Later operations such as image clipping will be considered.

  2. Developers don’t need to worry about running time permissions on Android6.0, as Album is already well handled.

  3. Support custom style styles, such as Toolbar colors, status bar colors, and so on.

  4. Built-in support for cameras, developers do not have to worry about the use of cameras, the Album automatically handled.

  5. Supports Activity and Fragment calls.

Technical exchange group: 46523908 image upload recommended use of NoHttp: NoHttp source code, at the same time, NoHttp detailed documentation has been published: NoHttp detailed use document

Demo Preview

Choose picture
Switching folders


preview

If you want to try it out, you can download the DEMO’s APK and play with it.

Method of use

Gradle:

compile 'com. Yanzhenjie: album: 1.0.0'Copy the code

Or Maven:

<dependency>
  <groupId>com.yanzhenjie</groupId>
  <artifactId>album</artifactId>
  <version>1.0.0</version>
  <type>pom</type>
</dependency>Copy the code

Eclipse please download the source code and convert it to Library Project.

Registration is required in mainifest. XML

<activity
    android:name="com.yanzhenjie.album.AlbumActivity"
    android:label="Atlas"
    android:configChanges="orientation|keyboardHidden|screenSize"
    android:theme="@style/Theme.AppCompat.Light.NoActionBar"
    android:windowSoftInputMode="stateAlwaysHidden|stateHidden" />Copy the code

Android :label=”xx” in xx is the title of the Activity, you can customize, other please copy.

Required permissions

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />Copy the code

Developers don’t need to worry about running time permissions on Android6.0, as Album is already well handled.

How to call

Call up the interface of the Album:

// 1. Use the default style and specify the number of options:
// The first parameter Activity/Fragment; The second request_code; The third allows you to select the number of photos, do not fill can be unlimited selection.
// Album.startAlbum(this, ACTIVITY_REQUEST_SELECT_PHOTO, 9);

// 2. Use the default style without specifying the number of options:
// Album.startAlbum(this, ACTIVITY_REQUEST_SELECT_PHOTO); // If the third parameter is left blank, you can select an infinite number of parameters.

// 3. Specify the style, and specify the number to select, if you do not want to limit the number passed in integer. MAX_VALUE;
Album.startAlbum(this, ACTIVITY_REQUEST_SELECT_PHOTO
    , 9                                                         // Specify the number of options.
    , ContextCompat.getColor(this, R.color.colorPrimary)        // Specify the color of the Toolbar.
    , ContextCompat.getColor(this, R.color.colorPrimaryDark));  // Specify the color of the status bar.Copy the code

Accept the result and override the onActivityResult() method on your Activity/Fragment:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 100) {
        if (resultCode == RESULT_OK) { // Check whether it succeeded.
            // Get the user selected image path List:
            List<String> pathList = Album.parseResult(data);
        } else if (resultCode == RESULT_CANCELED) { // The user deselected.
            // Prompt the user to deselect as required.}}}Copy the code

Pay attention to the point

Since it supports MaterialDesign, Google’s official support library has been referenced in the project:

compile 'com. Android. Support: appcompat - v7:24.2.1'
compile 'com. Android. Support: recyclerview - v7:24.2.1'
compile 'com. Android. Support: design: 24.2.1'Copy the code

confusion

All can be confused, if you encounter problems with confusion, please add the following rules.

-dontwarn com.yanzhenjie.album.** -keep class com.yanzhenjie.album.**{*; }Copy the code