android - onEnterAnimationComplete() is not called after an Activity Transaction -


i have 2 activities single shared object, imageview. both activities subclasses of appcompatactivity , share same theme:

<style name="apptheme" parent="theme.appcompat.light.noactionbar">     <!-- customize theme here. -->     <item name="colorprimary">@color/colorprimary</item>     <item name="colorprimarydark">@color/colorprimarydark</item>     <item name="coloraccent">@color/coloraccent</item>     <item name="android:windowactionbar">false</item>     <item name="android:windowcontenttransitions">true</item>     <item name="android:windowtranslucentstatus">false</item>     <item name="android:windowexittransition">@transition/transition_slide</item>     <item name="android:windowentertransition">@transition/transition_slide</item>     <!-- specify shared element transitions -->     <item name="android:windowsharedelemententertransition">         @transition/obj_transition</item>     <item name="android:windowsharedelementexittransition">         @transition/obj_transition</item> </style> 

activity calls activity b in following way:

intent intent = new intent(activitya.this, activityb.class); activityoptionscompat options = activityoptionscompat     .makescenetransitionanimation(activitya.this, view, "common_tag"); activitycompat     .startactivityforresult(activitya.this, intent, act_b_tag, options.tobundle()); 

on activity b, want start simple wobbling animation on same shared imageview. if start animation on oncreate method, result quite ugly because starts before end of activity transition. overwrite onenteranimationcomplete() method in activity b:

@override public void onenteranimationcomplete() {     log.d(tag, "animation complete");     animation anim = animationutils.loadanimation(this, r.anim.wobble);     findviewbyid(r.id.sharedview).startanimation(anim); } 

the problem is, nothing happens. activity , shared element transitions play, when end other animation won't start. checking logcat output see method not called. thoughts?

there's workaround that. can postpone activity enter transition, add predraw listener image (or whatever, it's you), setup animations, , start postponed enter transition.

postponeentertransition();  //  wait until animations set imageview.getviewtreeobserver().addonpredrawlistener(new viewtreeobserver.onpredrawlistener() {             @override             public boolean onpredraw() {                 imageview.getviewtreeobserver().removeonpredrawlistener(this);  //  run once                 enteranimation();  //  animations here                 startpostponedentertransition();  //  animations ran                  return true;             }         }); 

i don't know if onenteranimationcomplete() not getting called intended behaviour, if big oversight framework team.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -