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

Image duplication in ImageFragment #16

Closed
antonshkurenko opened this issue Oct 30, 2015 · 1 comment
Closed

Image duplication in ImageFragment #16

antonshkurenko opened this issue Oct 30, 2015 · 1 comment

Comments

@antonshkurenko
Copy link
Contributor

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();
            }
        }
@suarezjulian
Copy link
Owner

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.

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