imagepicker(图片选择器)

imagepicker(图片选择器)

图片选择器简介

imagepicker是一款用于在Android设备上获取照片(拍照或从相册、文件中选择)、压缩图片的开源工具库,目前最新版本V1.2.0

  • 从相册里面选择图片或者拍照获取照片
  • 浏览选择的本地或者网络图片
  • 保存图片

更新说明

v1.2.0(2017/7/11)

  1. 权限适配6.0,添加动态权限申请
  2. 优化项目

v1.1.0(2017/6/15)

  1. 修复图库无图片崩溃
  2. 修复三星手机拍照崩溃
  3. 修复部分手机(以小米为主)选择图片后内存溢出

v1.0(2016/8/4)

  1. 新增从相册里面选择图片或者拍照获取照片
  2. 新增浏览选择的本地或者网络图片
  3. 新增保存图片

如何引用

  • 配置gradle依赖
compile 'com.zzti.fengyongge:imagepicker:1.2.0'

如何使用

  • 拍照或者从图库选择图片
Intent intent = new Intent(MainActivity.this, PhotoSelectorActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
intent.putExtra("limit", number );//number是选择图片的数量
startActivityForResult(intent, 0);
  • 获取拍照或者图片地址
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        switch (requestCode) {
        case 0:
            if (data != null) {
                List<String> paths = (List<String>) data.getExtras().getSerializable("photos");//path是选择拍照或者图片的地址数组
                //处理代码

        }
            break;
        default:
            break;
        }
        super.onActivityResult(requestCode, resultCode, data);
        }
  • 浏览图片
 List<PhotoModel> single_photos = new ArrayList<PhotoModel>();
//PhotoModel 开发者将自己本地bean的list封装成PhotoModel的list,PhotoModel属性源码可查看
 Bundle bundle = new Bundle();
 bundle.putSerializable("photos",(Serializable)single_photos);
 bundle.putInt("position", position);//position预览图片地址
 bundle.putBoolean("isSave",true);//isSave表示是否可以保存预览图片,建议只有预览网络图片时设置true
 CommonUtils.launchActivity(PreViewActivity.this, PhotoPreviewActivity.class, bundle);
  • 保存图片

网络图片点击保存时,默认保存到内存卡,imagepicker文件夹下

实际效果

关于作者

Log.i("name", "fsuper");
Log.i("homepage", "http://fengyongge.github.io/");
Log.i("email", "fengyongge98@gmail.com");
Log.i("motto1", "可以让步,却不可以退缩,可以羞涩,却不可以软弱");
Log.i("motto2", "纸上得来终觉浅 绝知此事要躬行");

License

Copyright 2016 fengyongge

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.
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • ¥开启¥ 【iAPP实现进入界面执行逐一显】 〖2017-08-25 15:22:14〗 《//首先开一个线程,因...
    小菜c阅读 11,801评论 0 17
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 175,724评论 25 709
  • ¥开启¥ 【使用jni实现Tost】 〖2017-08-20 22:15:04〗 《在xx.cpp中写入以下代码€...
    小菜c阅读 4,353评论 0 1
  • 在项目的开发过程中我们需要从相册中选择图片、裁剪、压缩图片等功能, 图片选择 imagPicker图片选择框架 1...
    OlivineVip阅读 9,338评论 1 11
  • 车站 萌萌 正午的小汽车站,承载着最重的重量 一辆白色汽车呼喊着,带游子离家 站内的鲜花零落成泥,叶子破败 秋风裹...
    栖梧轩开心果阅读 1,430评论 0 0