liuling07 / PhotoPicker

An android library to pick photo from gallery
https://raw.githubusercontent.com/liuling07/PhotoPicker/master/sample.apk
Apache License 2.0
330 stars 131 forks source link

没有6.0权限控制 #15

Open VDshixiaoming opened 7 years ago

VDshixiaoming commented 7 years ago

启动就蹦,手动开了摄像和存储访问权限后才能运行。选择图片时往下滑就会报错,在PhotoPickerActivity的OnDestroy加

if(mProgressDialog != null){
            mProgressDialog.dismiss();
        }

后面滑动还是会报空指针错误

VDshixiaoming commented 7 years ago

java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.compress(android.graphics.Bitmap$CompressFormat, int, java.io.OutputStream)' on a null object reference at com.lling.photopicker.utils.ImageLoader.cacheBitmap2Disk(ImageLoader.java:317)

yangkile commented 7 years ago

你这种问题。。完全没法回答,照片权限不都是自己写吗。。

835700012 commented 6 years ago

May I have a question? how to use the picker in the dialog?

perfunctory commented 6 years ago

在执行内存缓存的线程里,把空值异常捕捉一下,可能是解析的图片出现问题 class DiskCacheThread extends Thread {

    String path;
    Bitmap bitmap;

    public DiskCacheThread(String path, Bitmap bitmap) {
        this.path = path;
        this.bitmap = bitmap;
    }

    @Override
    public void run() {
        try {
            String key = OtherUtils.hashKeyForDisk(path);
            DiskLruCache.Editor editor = mDiskLruCache.edit(key);
            if (editor != null) {
                OutputStream outputStream = editor.newOutputStream(0);
                if (cacheBitmap2Disk(bitmap, outputStream)) {
                    editor.commit();
                } else {
                    editor.abort();
                }
            }
            mDiskLruCache.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }catch (NullPointerException e){
            e.printStackTrace();
        }
    }
}