suarezjulian / WizardPager

Wizard Pager is a library that provides an example implementation of a Wizard UI on Android, it's based of Roman Nurik's wizard pager (https://github.com/romannurik/android-wizardpager)
Apache License 2.0
514 stars 149 forks source link

Image duplication in ImageFragment #16

Closed antonshkurenko closed 9 years ago

antonshkurenko commented 9 years ago

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 commented 9 years ago

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 https://github.com/TechFreak/WizardPager/issues/16.