fishwjy / MultiType-FilePicker

This is a light Android file picker library.
Apache License 2.0
1.4k stars 250 forks source link

Wrong image selection with camera #49

Open xPryds opened 5 years ago

xPryds commented 5 years ago

When choose use camera and take photo, it is showing 2 selected images. After, If I open an image preview and then close it, It will add +1. It will keep adding +1 even if I don't check the image preview.

Clicking in DONE btn send me back to previous activity with N times the camera image.

hututu-AE86 commented 5 years ago

I also had this problem with android 7.0. I don't have duplicate selection problems when I use debug breakpoints, so I think it has something to do with that broadcast. Can you talk about your solution?

sqbfine commented 5 years ago

I have the same question with SAMSUNG s7 & SAMSUNG s 8. I solved it this way. In ImagePickActivity :

private boolean findAndAddTakenImage(List<ImageFile> list) {
    for (ImageFile imageFile : list) {
        if (imageFile.getPath().equals(mAdapter.mImagePath)) {
            boolean contains = mSelectedList.contains(imageFile);
            if (contains) {
                return true;
            }
            mSelectedList.add(imageFile);
            mCurrentNumber++;
            mAdapter.setCurrentNumber(mCurrentNumber);
            tv_count.setText(mCurrentNumber + "/" + mMaxNumber);

            return true;   // taken image was found and added
        }
    }
    return false;    // taken image wasn't found
}