donglua / PhotoPicker

[DEPRECATED] Image Picker like Wechat
https://play.google.com/store/apps/details?id=me.iwf.PhotoPickerDemo
Apache License 2.0
2.83k stars 683 forks source link

拍摄照片结束后,直接加载图片,不用进图库页面 #265

Open waterpotter opened 6 years ago

waterpotter commented 6 years ago

感谢donglua大佬做出来的框架,今天添加功能的时候遇到了这个问题,看了一下源码,发现在PhotoPickerFragment中,openCamera()对应的onActivityResult()加上一下代码,可以实现该功能:

if (directories.size() > 0) { String path = captureManager.getCurrentPhotoPath(); Log.i("获取的图片路径", "onActivityResult: "+path); PhotoDirectory directory = directories.get(INDEX_ALL_PHOTOS); directory.getPhotos().add(INDEX_ALL_PHOTOS, new Photo(path.hashCode(), path)); directory.setCoverPath(path); photoGridAdapter.notifyDataSetChanged(); //===================开始==========================

            Intent intent = new Intent();
           ArrayList<String> selectedPhotos =new ArrayList<>();
           List<String> selectedPhotosls = photoGridAdapter.getCurrentPhotoPaths();
            selectedPhotos.add(selectedPhotosls.get(0));
            if (selectedPhotos != null && selectedPhotos.size() > 0) {
                intent.putStringArrayListExtra(KEY_SELECTED_PHOTOS, selectedPhotos);
                getActivity().setResult(RESULT_OK, intent);
                getActivity().finish();
            }

//====================结束========================

}


有不对的地方,可以指正^_^

SageLu commented 5 years ago

试了一下 可以的 ,但是选择相册的时候,最新拍的照片没有显示。?? (这个库存在的问题)