diff --git a/src/com/udinic/ActivitySplitAnimation/Activity1.java b/src/com/udinic/ActivitySplitAnimation/Activity1.java index 678fe28..4f3e144 100644 --- a/src/com/udinic/ActivitySplitAnimation/Activity1.java +++ b/src/com/udinic/ActivitySplitAnimation/Activity1.java @@ -16,7 +16,9 @@ public void onCreate(Bundle savedInstanceState) { @Override public void onClick(View v) { - ActivitySplitAnimationUtil.startActivity(Activity1.this, new Intent(Activity1.this, Activity2.class)); + Intent i = new Intent(Activity1.this, Activity2.class); + i.putExtra("doSplitAnimation", true); + ActivitySplitAnimationUtil.startActivity(Activity1.this, ); } }); } diff --git a/src/com/udinic/ActivitySplitAnimation/Activity2.java b/src/com/udinic/ActivitySplitAnimation/Activity2.java index d9245f8..d141b2a 100644 --- a/src/com/udinic/ActivitySplitAnimation/Activity2.java +++ b/src/com/udinic/ActivitySplitAnimation/Activity2.java @@ -9,14 +9,33 @@ public class Activity2 extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - - // Preparing the 2 images to be split - ActivitySplitAnimationUtil.prepareAnimation(this); + + // Get intent information for the split animation + Intent i = getIntent(); + boolean animate = i.getBooleanExtra("doSplitAnimation", false); + + // Once the doSplitAnimation extra has been read, we remoe it from intent so + // that the animation doesn't occur or other instances of onCreate() being + // called such as rotation. + if (i.hasExtra("doSplitAnimation")) + i.removeExtra("doSplitAnimation"); + + // Use split animation on if onCreate() is called from other activity. This + // is to counter the case of this onCreate being called when there is a + // rotation. + if (animate) + // Preparing the 2 images to be split + ActivitySplitAnimationUtil.prepareAnimation(this); setContentView(R.layout.act_two); - // Animating the items to be open, revealing the new activity - ActivitySplitAnimationUtil.animate(this, 1000); + // Use split animation on if onCreate() is called from other activity. This + // is to counter the case of this onCreate being called when there is a + // rotation. + if (animate) + // Animating the items to be open, revealing the new activity, with + // the animation duration as 1 sec. + ActivitySplitAnimationUtil.animate(this, 1000); } @Override