suarezjulian/WizardPager

Image duplication in ImageFragment

antonshkurenko opened this issue · 1 comments

I found, that if you place in your wizard pager amount of ImagePage, so when you will startActivityForResult returned result will overwrite every your image. I found the way to avoid this:

Changing request codes to:

private final int GALLERY_REQUEST_CODE = Math.abs((short) (hashCode() ^ (hashCode() >>> 16)) - 0);
private final int CAMERA_REQUEST_CODE = Math.abs((short) (hashCode() ^ (hashCode() >>> 16)) - 1);

This will make every ImageFragment unique.
Later change onActivityResult for:

if(requestCode == CAMERA_REQUEST_CODE) {
            if (resultCode == Activity.RESULT_OK) {
                imageView.setImageURI(mNewImageUri);
                writeResult();
            }
        } else if(requestCode == GALLERY_REQUEST_CODE) {
            if (resultCode == Activity.RESULT_OK && data != null) {
                mNewImageUri = data.getData();
                imageView.setImageURI(mNewImageUri);
                writeResult();
            }
        }

Hi, thanks for the info, if you could make a pull request for this that
would be great
On Oct 30, 2015 6:16 AM, "Anton Shkurenko" notifications@github.com wrote:

I found, that if you place in your wizard pager amount of ImagePage, so
when you will startActivityForResult returned result will overwrite every
your image. I found the way to avoid this:

Changing request codes to:

private final int GALLERY_REQUEST_CODE = Math.abs((short) (hashCode() ^ (hashCode() >>> 16)) - 0);
private final int CAMERA_REQUEST_CODE = Math.abs((short) (hashCode() ^ (hashCode() >>> 16)) - 1);

This will make every ImageFragment unique.
Later change onActivityResult for:

if(requestCode == CAMERA_REQUEST_CODE) {
if (resultCode == Activity.RESULT_OK) {
imageView.setImageURI(mNewImageUri);
writeResult();
}
} else if(requestCode == GALLERY_REQUEST_CODE) {
if (resultCode == Activity.RESULT_OK && data != null) {
mNewImageUri = data.getData();
imageView.setImageURI(mNewImageUri);
writeResult();
}
}


Reply to this email directly or view it on GitHub
#16.