Giter Site home page Giter Site logo

weiminsir / album Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yanzhenjie/album

0.0 2.0 0.0 12.37 MB

Android轻量级相册,支持单/多选、缩放、预览、按文件夹查看图片。

Home Page: http://blog.csdn.net/yanzhenjie1003/article/details/52975922

License: Apache License 2.0

Java 100.00%

album's Introduction

Album

  1. Album是一个Android开源相册,支持单/多选、缩放、预览、按文件夹查看图片,二期会考虑加入图片剪切等操作,这个功能将是非必选的。

  2. 开发者不需要担心Android6.0的运行时权限,Album已经非常完善的处理过了。

  3. 支持自定义样式风格,比如Toolbar颜色、状态栏颜色等。

  4. 内置支持了相机,开发者不用担心相机的使用问题,Album自动搞定。

  5. 支持ActivityFragment调用。

技术交流群:46523908
图片上传推荐使用NoHttp:NoHttp源码NoHttp详细使用文档

Demo效果预览


如果你想体验一把,你可以下载demo的apk来玩玩。

使用方法

Gradle:

compile 'com.yanzhenjie:album:1.0.0'

Or Maven:

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

Eclipse请下载源码自行转换成Library project。

mainifest.xml中需要注册

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

其中android:label="xx"中的xx是调起的Activity的标题,你可以自定义,其它请照抄即可。

需要的权限

<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" />

开发者不需要担心Android6.0的运行时权限,Album已经非常完善的处理过了。

如何调用

调起Album的界面:

// 1. 使用默认风格,并指定选择数量:
// 第一个参数Activity/Fragment; 第二个request_code; 第三个允许选择照片的数量,不填可以无限选择。
// Album.startAlbum(this, ACTIVITY_REQUEST_SELECT_PHOTO, 9);

// 2. 使用默认风格,不指定选择数量:
// Album.startAlbum(this, ACTIVITY_REQUEST_SELECT_PHOTO); // 第三个参数不填的话,可以选择无数个。

// 3. 指定风格,并指定选择数量,如果不想限制数量传入Integer.MAX_VALUE;
Album.startAlbum(this, ACTIVITY_REQUEST_SELECT_PHOTO
    , 9                                                         // 指定选择数量。
    , ContextCompat.getColor(this, R.color.colorPrimary)        // 指定Toolbar的颜色。
    , ContextCompat.getColor(this, R.color.colorPrimaryDark));  // 指定状态栏的颜色。

重写Activity/FragmentonActivityResult()方法:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 100) {
        if (resultCode == RESULT_OK) { // 判断是否成功。
            // 拿到用户选择的图片路径List:
            List<String> pathList = Album.parseResult(data);
        } else if (resultCode == RESULT_CANCELED) { // 用户取消选择。
            // 根据需要提示用户取消了选择。
        }
    }
}

注意点

由于支持了MaterialDesign,项目中已经引用了Google官方的的support库:

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'

混淆

都是可以混淆的,如果混淆遇到问题了,请添加如下规则。

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

Thanks

项目中的缩放是用的PhotoView,特别感谢作者的付出。

License

Copyright 2016 Yan Zhenjie

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

album's People

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.