Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
waterpotter opened this issue Aug 17, 2018 · 1 comment
Open

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

waterpotter opened this issue Aug 17, 2018 · 1 comment

Comments

@waterpotter
Copy link

waterpotter commented Aug 17, 2018

感谢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
Copy link

SageLu commented Mar 5, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants