Created
July 24, 2013 06:42
-
-
Save chrislacy/6068493 to your computer and use it in GitHub Desktop.
So long as you pass in a valid View, and are using Jelly Bean or later, the animation should automatically apply.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@SuppressLint("NewApi") | |
public boolean startActivity(View v, Intent intent, Object tag) { | |
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | |
// Only launch using the new animation if the shortcut has not opted out (this is a | |
// private contract between launcher and may be ignored in the future). | |
boolean useLaunchAnimation = (v != null) && | |
!intent.hasExtra(INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION) && | |
Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; | |
if (useLaunchAnimation) { | |
ActivityOptions opts = ActivityOptions.makeScaleUpAnimation(v, 0, 0, | |
v.getMeasuredWidth(), v.getMeasuredHeight()); | |
startActivity(intent, opts.toBundle()); | |
} else { | |
startActivity(intent); | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment