Giter Site home page Giter Site logo

lucksiege / pictureselector Goto Github PK

View Code? Open in Web Editor NEW
13.2K 196.0 3.0K 529.37 MB

Picture Selector Library for Android or 图片选择器

License: Apache License 2.0

Java 99.87% Kotlin 0.13%
android android-image-selector camera compress glide image-compression image-picker images multi-selector photo

pictureselector's People

Contributors

arakawa96 avatar chavesgu avatar citrussss avatar eggyu avatar luck1991 avatar lucksiege avatar po1xiao avatar towayamashita avatar yanivshaked avatar yomigatz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pictureselector's Issues

录制视频问题

为什么选择视频,跳到录制界面 点击录制 没有效果 点击设置 闪光灯 切换摄像头都没有反映

两个问题,关于bug和建议

bug:获取图片,选择4张以上照片时,裁剪的时候出现问题,具体是后面的图片裁剪,会一直出现之前裁剪过的照片。
建议:能不能拍照的时候,给照片设置名字

compile 'com.github.LuckSiege.PictureSelector:picture_library:v1.2.5'引入报错

报错Error:Failed to resolve: :picture_library-release:
Open File
已经添加allprojects {
repositories {
jcenter()
maven { url 'https://jitpack.io' }
}
}
也不好使啊

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "24.0.0"

defaultConfig {
    applicationId "com.wyys.seller"
    minSdkVersion 18
    targetSdkVersion 23
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}
repositories {
    flatDir {
        dirs 'libs'
    }
}

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

dependencies {
compile files('libs/qiniu-android-sdk-7.0.3.jar')
compile files('libs/qiniu-java-sdk-7.0.4.jar')
compile 'com.android.support:support-v4:24.2.1'
compile 'com.android.support:appcompat-v7:24.2.1'
testCompile 'junit:junit:4.12'
compile 'com.google.code.gson:gson:2.8.0'
compile files('libs/dynamic-4.3.0.jar')
compile files('libs/universal-image-loader-1.9.3-with-sources.jar')
compile 'com.google.zxing:core:3.3.0'
android {
useLibrary 'org.apache.http.legacy'//解决6.0 httpclient包不支持
}
compile 'me.yokeyword:indexablerecyclerview:1.1.0'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.loopj.android:android-async-http:1.4.9'
compile(name: 'ucrop-release', ext: 'aar')
compile(name: 'picture_library-release', ext: 'aar')
compile 'com.github.LuckSiege.PictureSelector:picture_library:v1.2.5'
}

建议

选择后的图片只能进行删除操作,不能预览,希望增加预览操作

建议

  1. Options这个对象,也是一个序列化的对象,有特定的作用域,所以感觉这块应该用Builder来封装一下。
    2.根据第一点,设计成Builder模式,改造图片的启动方式。
    3.剪裁和选择应该是两件事,个人觉得不应该放在一起合并成一个库,顺便说一下,你用了ucrop,为啥不做声明?
  2. Constants名字可以考虑改一下。
    5.确实适配上还有一些问题,我测试下来,在小米4的6.0系统预览直接crash。
    6.图片加载的速度跟不上,这个真的是硬伤。

java.lang.NoSuchFieldError 某些机型会报这个错

java.lang.NoSuchFieldError: No static field preview_pager of type I in class Lcom/yalantis/ucrop/R$id; or its superclasses (declaration of 'com.yalantis.ucrop.R$id' appears in /data/app/com.demo.zjy-1/base.apk)
at com.yalantis.ucrop.ui.PreviewActivity.onCreate(PreviewActivity.java:61)
at android.app.Activity.performCreate(Activity.java:6247)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2606)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2750)
at android.app.ActivityThread.access$1000(ActivityThread.java:187)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1595)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:224)
at android.app.ActivityThread.main(ActivityThread.java:5911)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1113)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:879)

拍照问题

private static File createMediaFile(Context context, String parentPath, int type) {
String state = Environment.getExternalStorageState();
File rootDir = state.equals(Environment.MEDIA_MOUNTED) ? Environment.getExternalStorageDirectory() : context.getCacheDir();

    File folderDir = new File(rootDir.getAbsolutePath() + parentPath);
    if (!folderDir.exists() && folderDir.mkdirs()) {

    }

    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.CHINA).format(new Date());
    String fileName = APP_NAME + "_" + timeStamp + "";
    File tmpFile = null;
    switch (type) {
        case 1:
            tmpFile = new File(folderDir, fileName + POSTFIX);
            break;
        case 2:
            tmpFile = new File(folderDir, fileName + POST_VIDEO);
            break;
    }
    return tmpFile;
}

folderDir.mkdirs() false

添加依赖失败

在app的build中添加 compile 'com.github.LuckSiege.PictureSelector:picture_library:v1.2.4'
报错,表示failed to resolve

裁剪图片1:1等比例与自定义裁剪宽高度有冲突吗?

我设置了裁剪1:1的比例,然后设置裁剪宽高为config.setCropW(100); config.setCropH(100); 可是到图片裁剪界面还是1:1模式下的,为什么不是100100的裁剪界面? 我把裁剪比例模式关了 config.setCopyMode(copyMode);这个注释了,宽高为config.setCropW(100); config.setCropH(100); 在裁剪界面,裁剪方框大小和原来1:1的一致,而不是100100的效果?这是怎么回事呢?

小的建议

多选当我已经选过某几张图片的时候,再次进入选择图片应该默认选中状态。这个功能貌似没有在当前版本看到。

小米5系统7.0在预览图片的时候报错

这是错误信息
01-09 18:56:43.522 1471-2709/? W/ActivityManager: Exception in new application when starting activity com.luck.pictureselector/com.yalantis.ucrop.ui.PreviewActivity
android.os.TransactionTooLargeException: data parcel size 663160 bytes
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:615)
at android.app.ApplicationThreadProxy.scheduleLaunchActivity(ApplicationThreadNative.java:883)
at com.android.server.am.ActivityStackSupervisor.realStartActivityLocked(ActivityStackSupervisor.java:1329)
at com.android.server.am.ActivityStackSupervisor.attachApplicationLocked(ActivityStackSupervisor.java:892)
at com.android.server.am.ActivityManagerService.attachApplicationLocked(ActivityManagerService.java:6770)
at com.android.server.am.ActivityManagerService.attachApplication(ActivityManagerService.java:6834)
at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:539)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2826)
at android.os.Binder.execTransact(Binder.java:565)
我测试了华为7.0系统的,却没有这个问题,其他7.0以下的手机都没问题,请问这个如何解决呢?

支持最低版本

请问一下这库支持的最低安卓系统版本是多少呢,是demo是16+的,有点高呢

这个是什么media为啥没有这个能解释一下么

private PictureConfig.OnSelectResultCallback resultCallback = new PictureConfig.OnSelectResultCallback() {

@OverRide

public void onSelectSuccess(List< LocalMedia> resultList) {
if (media.isCompressed()){
// 注意:如果压缩过,在上传的时候,取 media.getCompressPath(); // 压缩图compressPath
} else {
// 注意:没有压缩过,在上传的时候,取 media.getPath(); // 原图path
} else{

       // 注意:如果media.getCatPath();不为空的话 就代表裁剪的图片,上传时可取,但是如果又压缩过,则取最终压缩过的compressPath

       }

       selectMedia = resultList;  

      if (selectMedia != null) {

          adapter.setList(selectMedia);

          adapter.notifyDataSetChanged();

      }
  }

};

建议

点击拍照或者录像功能,现在您做的是先进入相册在拍摄,是否可以做一个选择,直接拍摄 or先进入相册,我们能自己配置,这样根据需求选择相应功能就好!

单张预览后是否能加上‘完成’和‘取消’的回调?

业务需求是上传用户头像,因此只需要选择一张照片,并且要支持裁剪和预览,那么,目前设置单张选择并裁剪后,调用代码:
PictureConfig.externalPicturePreview(ModifyPersonActivity.this, position, list);
可以实现预览,但问题是,在打开预览界面之后,页面上没有提供后续操作的按钮。比如流程:
1,选择单张图片或拍照后
2,进入裁剪页面,完成后
3,进入预览页面,在该页面提供完成的事件回调或广播通知,为之后的操作提供方便,若用户点击返回,则不执行任何后续动作。

不知道以上这种需求,作者是否可以实现满足?

关于裁剪比例,裁剪宽高和压缩之间的关系

你好,我这边这三个参数设置为如下:(裁剪比例1:1,裁剪宽高1200,1200,压缩宽高1100,1100)
config.setCopyMode(copyMode);//1:1 config.setCompress(isCompress);//true config.setEnablePixelCompress(false); config.setEnableQualityCompress(true); config.setMaxSelectNum(maxSelectNum); config.setSelectMode(selectMode); config.setShowCamera(isShow); config.setEnablePreview(enablePreview); config.setEnableCrop(enableCrop); config.setPreviewVideo(isPreviewVideo); config.setRecordVideoDefinition(FunctionConfig.HIGH);// 视频清晰度 config.setRecordVideoSecond(60);// 视频秒数 config.setCropW(cropW);//1200 config.setCropH(cropH);//1200 config.setCheckNumMode(isCheckNumMode); config.setCompressQuality(100); config.setImageSpanCount(4); config.setSelectMedia(selectMedia); config.setCompressFlag(compressFlag); config.setCompressW(compressW);//1100 config.setCompressH(compressH);//1100
回调的代码:
if (selectMedia.get(0).getPath() != null) {
Bitmap bt1 = BitmapFactory.decodeFile(selectMedia.get(0).getPath());
Log.i("bt1", "高"+bt1.getHeight() + "宽" + bt1.getWidth());
bt1.recycle();
Log.i("原图", new File(selectMedia.get(0).getPath()).length() / 1024 + "k");
}
if (selectMedia.get(0).getCutPath() != null) {
Bitmap bt2 = BitmapFactory.decodeFile(selectMedia.get(0).getCutPath());
Log.i("bt2", "高"+bt2.getHeight() + "宽" + bt2.getWidth());
bt2.recycle();
Log.i("裁剪", new File(selectMedia.get(0).getCutPath()).length() / 1024 + "k");
}
if (selectMedia.get(0).getCompressPath() != null) {
Bitmap bt3 = BitmapFactory.decodeFile(selectMedia.get(0).getCompressPath());
Log.i("bt3", "高"+bt3.getHeight() + "宽" + bt3.getWidth());
bt3.recycle();
Log.i("压缩", new File(selectMedia.get(0).getCompressPath()).length() / 1024 + "k");
}
但是打印的结果为下面的:

02-14 10:47:12.958 9673-22355/com.luck.pictureselector I/BitmapCropTask: Should crop: true
02-14 10:47:15.438 9673-9673/com.luck.pictureselector I/bt1: 高4160宽3120
02-14 10:47:15.438 9673-9673/com.luck.pictureselector I/原图: 3310k
02-14 10:47:15.578 9673-9673/com.luck.pictureselector I/bt2: 高1200宽1200
02-14 10:47:15.578 9673-9673/com.luck.pictureselector I/裁剪: 938k
02-14 10:47:15.588 9673-9673/com.luck.pictureselector I/bt3: 高300宽300
02-14 10:47:15.588 9673-9673/com.luck.pictureselector I/压缩: 71k
02-14 10:47:15.588 9673-9673/com.luck.pictureselector I/callBack_result: 1
02-14 10:47:15.608 9673-9673/com.luck.pictureselector I/Choreographer: Skipped 57 frames! The application may be doing too much work on its main thread.
02-14 10:47:15.608 9673-9673/com.luck.pictureselector I/compress image result: 71k

裁剪后的宽高和我设置的是一样的1200,但是压缩后怎么直接变为300,300了呢?并不是1100,1100

拼写和权限小问题

FunctionConfig 类里的裁剪比如 COPY_MODEL_DEFAULT前缀拼写应该是CROP,我还特地查了一下。调用相机权限拒绝后就只是弹出提示没有权限,最好是拒绝后每次再进入提示跳转到应用的权限设置页面

拍摄视频质量问题

拍摄视频,10秒,高质量的太大,50多M,低质量的太小,模糊看不清,能否取个中等值,或指定大小?

提几个问题

1、我设置最大图片为9张时,选择两张图片回到主页面,想再去多选择几张图片,但是回到主页面,前面选择的两张图片消失了,只剩下我后来选择的几张图片了。
2、你的demo设置数量能到负数,这个改一下。
3、设置最大数量超过9张时,如10张,选完10张图片再去删减图片,那个选择图片的加号不见了,不能继续选择图片
4、目前为止没有发现裁剪功能怎么使用

取消选择那里也加一个回调吧

有时候取消选择图片也需要回调给业务方确认的,业务方确认后回滚一些变量或弹出一些提示,所以加一下比较好。比如说WebView选择图片,如果取消了选择图片,要给WebView的回调选择了空图片,然后重置WebView的回调,不然会有问题。我现在的做法是在WebView的Activity的onResume方法里重置WebView的回调,虽然解决了问题,但是这种实现很不好。望改进。

我选择了5张图片,回到主页页面后,我想删除其中的两张时,报错。

01-06 09:38:50.605 8485-8485/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.luck.pictureselector, PID: 8485
java.lang.IndexOutOfBoundsException: Invalid index 2, size is 2
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
at java.util.ArrayList.remove(ArrayList.java:403)
at com.luck.pictureselector.MainActivity$3.onAddPicClick(MainActivity.java:127)
at com.luck.pictureselector.adapter.GridImageAdapter$3.onClick(GridImageAdapter.java:127)
at android.view.View.performClick(View.java:5207)
at android.view.View$PerformClick.run(View.java:21177)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5458)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)

刚进app点+号添加图片时Resources$NotFoundException: String resource ID

                                                                     Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x7f07002b
                                                                        at android.content.res.Resources.getText(Resources.java:299)
                                                                        at android.content.res.Resources.getString(Resources.java:385)
                                                                        at com.luck.picture.lib.ui.PictureAlbumDirectoryActivity.onCreate(PictureAlbumDirectoryActivity.java:76)

4.0系统相册数据为空

非常牛逼的库,感谢作者。
PictureImageGridActivity中做权限判断时,应该加系统判断,不然我4.0的三星平板没获取到相册。
if (Build.VERSION.SDK_INT >= 23) {
// 第一次启动ImageActivity,没有获取过相册列表
// 先判断手机是否有读取权限,主要是针对6.0已上系统
if (hasPermission(Manifest.permission.READ_EXTERNAL_STORAGE)) {
readLocalMedia();
} else {
requestPermission(FunctionConfig.READ_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE);
}
}else{
readLocalMedia();
}

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.