Giter VIP home page Giter VIP logo

pictureselector's Introduction

PictureSelector

最近项目中用到多图选择上传的需求,随后百度了一下用了别人写的demo,发现在很多机型上各种不适,闪退等问题,严重影响使用,后面我自己写了一个,公司20几款手机全部通过,在腾讯云测中也使用了4,50款手机测试,没有发现问题,特分享出来。 功能特点:

1.适配android7.0系统

2.解决部分机型裁剪闪退问题

4.解决图片过大oom闪退问题

5.动态获取系统权限,避免闪退

6.支持相片or视频的单选和多选

7.支持裁剪比例设置,如常用的 1:1、3:4、3:2、16:9 默认为图片大小

8.支持视频预览

9.支持gif图片

10.支持一些常用场景设置:如:是否裁剪、是否预览图片、是否显示相机等

11.新增自定义主题设置

12.新增图片勾选样式设置

13.新增图片裁剪宽高设置

14.新增图片压缩处理

15.新增录视频最大时间设置

16.新增视频清晰度设置

17.新增QQ选择风格,带数字效果

项目会一直维护,发现问题欢迎提出~  会第一时间修复哟~   联系方式[email protected]  希望用得着的朋友点个start,你们的支持才是我继续下去的动力,在此先谢过~

app-build 引入compile 'com.github.LuckSiege:PictureSelector:v1.0.7'  注:之前引入如有报错,请引入最新版本

项目根目录

allprojects {

repositories {

    maven { url 'https://jitpack.io' }
    
    jcenter()
    
}

}

Options options = new Options();

options.setType(selectType); 1图片 or 2视频 LocalMediaLoader.TYPE_IMAGE,TYPE_VIDEO

                    options.setCopyMode(copyMode); 裁剪比例 默认 1:1 3:4 3:2 16:9 可参考 Constants.COPY_MODEL_1_1

                    options.setCompress(isCompress); 是否压缩

options.setMaxSelectNum(maxSelectNum - images.size()); 最大可选数量

                    options.setSelectMode(selectMode); 2单选 or 1多选 MODE_MULTIPLE MODE_SINGLE

                    options.setShowCamera(isShow); 是否显示相机

                    options.setEnablePreview(enablePreview); 是否预览

                    options.setEnableCrop(enableCrop); 是否裁剪

                  options.setPreviewVideo(isPreviewVideo); 是否预览视频(播放)

                    options.setCropW(cropW); 裁剪宽

                    options.setCropH(cropH); 裁剪高

options.setRecordVideoDefinition(Constants.HIGH);// 视频清晰度 Constants.HIGH 清晰 Constants.ORDINARY 普通 低质量

options.setRecordVideoSecond(60);// 视频秒数

options.setCheckNumMode(isCheckNumMode); 是否显示QQ选择风格(带数字效果)

                    AlbumDirectoryActivity.startPhoto(MainActivity.this, options);

 @Override

protected void onActivityResult(int requestCode, int resultCode, Intent data) {

 if (resultCode == RESULT_OK) {
 
        switch (requestCode) {
        
            case Constants.REQUEST_IMAGE:
            
                ArrayList<String> result = (ArrayList<String>) data.getSerializableExtra(Constants.REQUEST_OUTPUT);
                if (result != null) {
                    images.addAll(result);
                    adapter.setList(images);
                    adapter.notifyDataSetChanged();
                }
                break;
        }
    }
}

image image image image image image image image image image

pictureselector's People

Contributors

luck1991 avatar

Watchers

James Cloos avatar Android is my Life 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.