The current repo belongs to Paused status, and some functions are restricted. For details, please refer to the description of repo status
10 Star 52 Fork 9

Vanish / ImagePicker
Paused

Create your Gitee Account
Explore and code with more than 8 million developers,Free private repositories !:)
Sign up
Clone or Download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

ImagePicker

Android自定义图片选择器,适配Android7.0


希望了解该项目的朋友可参考下面的博客
http://blog.csdn.net/lwk520136/article/details/65647033
http://www.jianshu.com/p/46b5918976e1

效果图:





使用方法:

1.添加Gradle依赖:

最新的版本号以这里为准

  #your-version是指的你自己项目里引用的版本号
  #last-version请查看上面的最新版本号

  #AndroidStudio3.0以下
  //在自己项目里添加Glide的引用(Glide要求4.0版本以上)
  compile("com.github.bumptech.glide:glide:your-version") {
      exclude(group: 'com.android.support', module: 'support-v4')
  }
  //在自己项目里添加support-V4的引用
  compile "com.android.support:support-v4:your-version"
  //添加该库引用,并去除自带的support-V4、Glide引用,防止版本冲突
  compile("com.lwkandroid:ImagePicker:last-verison") {
      exclude(group: 'com.android.support', module: 'support-v4')
      exclude(group: 'com.github.bumptech.glide', module: 'glide')
  }

  #AndroidStudio3.0以上
  //在自己项目里添加Glide的引用(Glide要求4.0版本以上)
  implementation("com.github.bumptech.glide:glide:your-version") {
      exclude(group: 'com.android.support', module: 'support-v4')
  }
  //在自己项目里添加support-V4的引用
  implementation "com.android.support:support-v4:your-version"
  //添加该库引用,并去除自带的support-V4、Glide引用,防止版本冲突
  implementation("com.lwkandroid:ImagePicker:last-verison") {
      exclude(group: 'com.android.support', module: 'support-v4')
      exclude(group: 'com.github.bumptech.glide', module: 'glide')
  }
  • 注意:如果自己项目里的Glide版本低于4.0,那么需要实现接口IImagePickerDisplayer,调用的时候传进去:
//代码中实现IImagePickerDisplayer接口
public class YourDisplayer implements IImagePickerDisplayer
{
    @Override
    public void display(Context context, String url, ImageView imageView, int maxWidth, int maxHeight)
    {
        //TODO 实现加载图片的方法
    }

    @Override
    public void display(Context context, String url, ImageView imageView, int placeHolder, int errorHolder, int maxWidth, int maxHeight)
    {
        //TODO 实现加载图片的方法
    }
}

//调用的时候手动添加.displayer()
    new ImagePicker()
        ... //省略配置参数
        .displayer(new YourDisplayer()) //改为自定义图片加载器,必须调用!!!
        .start(this, REQUEST_CODE); //自定义RequestCode

2.代码中使用:

    //发起图片选择
    new ImagePicker()
        .pickType(ImagePickType.MUTIL) //设置选取类型(拍照ONLY_CAMERA、单选SINGLE、多选MUTIL)
        .maxNum(9) //设置最大选择数量(此选项只对多选生效,拍照和单选都是1,修改后也无效)
        .needCamera(true) //是否需要在界面中显示相机入口(类似微信那样)
        .cachePath(cachePath) //自定义缓存路径(拍照和裁剪都需要用到缓存)
        .doCrop(1,1,300,300) //裁剪功能需要调用这个方法,多选模式下无效,参数:aspectX,aspectY,outputX,outputY
        .displayer(new GlideImagePickerDisplayer()) //自定义图片加载器,默认是Glide实现的,可自定义图片加载器
        .start(this, REQUEST_CODE); //自定义RequestCode

    //重写Activity或Fragment中OnActivityResult()
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data)
    {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == REQUEST_CODE && resultCode == RESULT_OK && data != null)
        {
            //获取选择的图片数据
            List<ImageBean> resultList = data.getParcelableArrayListExtra(ImagePicker.INTENT_RESULT_DATA);
        }
    }

混淆配置

-dontwarn com.lwkandroid.imagepicker.**
-keep class com.lwkandroid.imagepicker.**{*;}

注意事项

最新版本采用了自定义FileProvider的策略,故不用再修改清单文件。
参考博客:http://www.cnblogs.com/liushilin/p/6602364.html

感谢

项目中裁剪模块修改自开源项目:https://github.com/oginotihiro/cropview
感谢所有为开源做出贡献的人!

Repository Comments ( 0 )

Sign in to post a comment

About

Android自定义图片选择器,图片选择类似微信样式,自带裁剪功能 expand collapse
Android
Apache-2.0
Cancel

Releases

No release

ImagePicker

Contributors

All

Activities

Load More
can not load any more
Android
1
https://gitee.com/vanish136_admin/ImagePicker.git
git@gitee.com:vanish136_admin/ImagePicker.git
vanish136_admin
ImagePicker
ImagePicker
master

Search