PhotoView icon indicating copy to clipboard operation
PhotoView copied to clipboard

Get Wrong Animation effect when use ActivityOptions.makeSceneTransitionAnimation

Open bearprada opened this issue 11 years ago • 13 comments

it's a new transition animation in Android 5.0. but PhotoView will get wrong size when play animation like hhlyt

bearprada avatar Feb 11 '15 04:02 bearprada

Would love to see this fixed too. It makes Lollipop transition unusable. I tried to postpone the transition by calling startPostponedEnterTransition in OnPreDrawListener but it doesn't change a thing. I tried to extend ChangeImageTransform to add logs and compare these values with the ones that I get when using a simple ImageView instead of a PhotoView, but everything seems to be the same. Does anyone have an idea?

nicomott avatar Feb 19 '15 09:02 nicomott

Same problem. The only way i workarounded it: wrap imageviews into PhotoViewAttachers on enter animation finish. And clean PhotoViewAttachers on destroy views or activity exit

mykola-dev avatar Sep 29 '15 14:09 mykola-dev

Can you share the code to do this? I'm struggling with this problem too, but don't want to move away from PhotoView

tom-anders avatar Oct 03 '15 16:10 tom-anders

https://github.com/deviant-studio/VKontakte-Plus/blob/master/app/src/main/java/ds/vkplus/ui/activity/PhotosActivity.kt it's on kotlin though

mykola-dev avatar Oct 03 '15 17:10 mykola-dev

Doesn't really help me. but thanks - Hope this gets fixed soon or a workaround is found

tom-anders avatar Oct 04 '15 07:10 tom-anders

Same here. I currently work around this by having 2 ImageViews in the 2nd activity, a standard ImageView for the transition, and a PhotoView that gets displayed when the transition is over on top of it

nat-e avatar Oct 19 '15 18:10 nat-e

Is there any news on this?

Having an extra standard ImageView might work but then it breaks (for various reasons) when closing with ActivityCompat.finishAfterTransition().

If you happen to know what’s wrong, it should not be difficult to write a ChangeImageTransform extension, like:

public class ChangePhotoTransform extends ChangeImageTransform {

    private static final String PROPNAME_MATRIX = “android:changeImageTransform:matrix”;
    private static final String PROPNAME_BOUNDS = “android:changeImageTransform:bounds”;

    @Override
    public void captureStartValues(TransitionValues transitionValues) {
        if (transitionValues.view instanceof PhotoView) {
            capturePhotoValues(transitionValues);
        } else {
            super.captureStartValues(transitionValues);
        }
    }

    @Override
    public void captureEndValues(TransitionValues transitionValues) {
        if (transitionValues.view instanceof PhotoView) {
            capturePhotoValues(transitionValues);
        } else {
            super.captureEndValues(transitionValues);
        }
    }

    private void capturePhotoValues(TransitionValues transitionValues) {
        PhotoView view = (PhotoView) transitionValues.view;
        if (view.getVisibility() != View.VISIBLE) return;

        Map<String, Object> values = transitionValues.values;
        // Then...
        values.put(PROPNAME_BOUNDS, goodRect);
        // And finally....
        values.put(PROPNAME_MATRIX, goodMatrix);
    }
}

The current implementation of ChangeImageTransform is quite simple. I did my best in the past hours, but with no luck.

natario1 avatar Mar 17 '16 19:03 natario1

I had similar animation issue. Magic call photoViewAttacher.update() helped in my case.

public class DetailsTransition extends ChangeImageTransform {
    @Override
    public void captureStartValues(TransitionValues transitionValues) {
        updateAttacher(transitionValues);
        super.captureStartValues(transitionValues);
    }

    @Override
    public void captureEndValues(TransitionValues transitionValues) {
        updateAttacher(transitionValues);
        super.captureEndValues(transitionValues);
    }

    private static void updateAttacher(TransitionValues transitionValues) {
        View view = transitionValues.view;
        if (view instanceof PhotoView) {
            PhotoView imageView = (PhotoView) view;
            PhotoViewAttacher photoViewAttacher = (PhotoViewAttacher) imageView.getIPhotoViewImplementation();
            photoViewAttacher.update();
        }
    }
}

andrey-blak avatar Apr 05 '16 17:04 andrey-blak

Why not use imageview and PhotoVIewAttacher, something like this: public void onTransitionEnd(Transition transition) { PhotoViewAttacher attacher = new PhotoViewAttacher(); } It seems to have fixed the issue.

hajola avatar May 28 '16 10:05 hajola

This should be resolved in 1.3.0 thanks to @Rexee

Jawnnypoo avatar Aug 02 '16 23:08 Jawnnypoo

thanks @Rexee 👍

bearprada avatar Aug 03 '16 00:08 bearprada

Seems like this issue reemerged in 2.1.3 Downgrading to 2.0.0 helped

ucmobdev avatar Mar 02 '18 13:03 ucmobdev

Everything works fine for me on 2.2.0

tom-anders avatar Nov 12 '18 16:11 tom-anders