use of android.view.animation.AnimationSet in project android_frameworks_base by crdroidandroid.
the class AppTransition method createClipRevealAnimationLocked.
private Animation createClipRevealAnimationLocked(int transit, boolean enter, Rect appFrame, Rect displayFrame) {
final Animation anim;
if (enter) {
final int appWidth = appFrame.width();
final int appHeight = appFrame.height();
// mTmpRect will contain an area around the launcher icon that was pressed. We will
// clip reveal from that area in the final area of the app.
getDefaultNextAppTransitionStartRect(mTmpRect);
float t = 0f;
if (appHeight > 0) {
t = (float) mTmpRect.top / displayFrame.height();
}
int translationY = mClipRevealTranslationY + (int) (displayFrame.height() / 7f * t);
int translationX = 0;
int translationYCorrection = translationY;
int centerX = mTmpRect.centerX();
int centerY = mTmpRect.centerY();
int halfWidth = mTmpRect.width() / 2;
int halfHeight = mTmpRect.height() / 2;
int clipStartX = centerX - halfWidth - appFrame.left;
int clipStartY = centerY - halfHeight - appFrame.top;
boolean cutOff = false;
// and extending the clip rect from that edge.
if (appFrame.top > centerY - halfHeight) {
translationY = (centerY - halfHeight) - appFrame.top;
translationYCorrection = 0;
clipStartY = 0;
cutOff = true;
}
if (appFrame.left > centerX - halfWidth) {
translationX = (centerX - halfWidth) - appFrame.left;
clipStartX = 0;
cutOff = true;
}
if (appFrame.right < centerX + halfWidth) {
translationX = (centerX + halfWidth) - appFrame.right;
clipStartX = appWidth - mTmpRect.width();
cutOff = true;
}
final long duration = calculateClipRevealTransitionDuration(cutOff, translationX, translationY, displayFrame);
// Clip third of the from size of launch icon, expand to full width/height
Animation clipAnimLR = new ClipRectLRAnimation(clipStartX, clipStartX + mTmpRect.width(), 0, appWidth);
clipAnimLR.setInterpolator(mClipHorizontalInterpolator);
clipAnimLR.setDuration((long) (duration / 2.5f));
TranslateAnimation translate = new TranslateAnimation(translationX, 0, translationY, 0);
translate.setInterpolator(cutOff ? TOUCH_RESPONSE_INTERPOLATOR : mLinearOutSlowInInterpolator);
translate.setDuration(duration);
Animation clipAnimTB = new ClipRectTBAnimation(clipStartY, clipStartY + mTmpRect.height(), 0, appHeight, translationYCorrection, 0, mLinearOutSlowInInterpolator);
clipAnimTB.setInterpolator(TOUCH_RESPONSE_INTERPOLATOR);
clipAnimTB.setDuration(duration);
// Quick fade-in from icon to app window
final long alphaDuration = duration / 4;
AlphaAnimation alpha = new AlphaAnimation(0.5f, 1);
alpha.setDuration(alphaDuration);
alpha.setInterpolator(mLinearOutSlowInInterpolator);
AnimationSet set = new AnimationSet(false);
set.addAnimation(clipAnimLR);
set.addAnimation(clipAnimTB);
set.addAnimation(translate);
set.addAnimation(alpha);
set.setZAdjustment(Animation.ZORDER_TOP);
set.initialize(appWidth, appHeight, appWidth, appHeight);
anim = set;
mLastHadClipReveal = true;
mLastClipRevealTransitionDuration = duration;
// If the start rect was full inside the target rect (cutOff == false), we don't need
// to store the translation, because it's only used if cutOff == true.
mLastClipRevealMaxTranslation = cutOff ? Math.max(Math.abs(translationY), Math.abs(translationX)) : 0;
} else {
final long duration;
switch(transit) {
case TRANSIT_ACTIVITY_OPEN:
case TRANSIT_ACTIVITY_CLOSE:
duration = mConfigShortAnimTime;
break;
default:
duration = DEFAULT_APP_TRANSITION_DURATION;
break;
}
if (transit == TRANSIT_WALLPAPER_INTRA_OPEN || transit == TRANSIT_WALLPAPER_INTRA_CLOSE) {
// If we are on top of the wallpaper, we need an animation that
// correctly handles the wallpaper staying static behind all of
// the animated elements. To do this, will just have the existing
// element fade out.
anim = new AlphaAnimation(1, 0);
anim.setDetachWallpaper(true);
} else {
// For normal animations, the exiting element just holds in place.
anim = new AlphaAnimation(1, 1);
}
anim.setInterpolator(mDecelerateInterpolator);
anim.setDuration(duration);
anim.setFillAfter(true);
}
return anim;
}
use of android.view.animation.AnimationSet in project android_frameworks_base by AOSPA.
the class ListWithDisappearingItemBug method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Toast.makeText(this, "Make sure you rotate screen to see bug", Toast.LENGTH_LONG).show();
// Get a cursor with all people
Cursor c = getContentResolver().query(People.CONTENT_URI, null, null, null, null);
startManagingCursor(c);
ListAdapter adapter = new SimpleCursorAdapter(this, // Use a template that displays a text view
R.layout.list_with_disappearing_item_bug_item, // Give the cursor to the list adatper
c, // Map the NAME column in the people database to...
new String[] { People.NAME }, // The "text1" view defined in the XML template
new int[] { R.id.text1 });
setListAdapter(adapter);
AnimationSet set = new AnimationSet(true);
Animation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setDuration(50);
set.addAnimation(animation);
animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f);
animation.setDuration(100);
set.addAnimation(animation);
LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f);
ListView listView = getListView();
listView.setLayoutAnimation(controller);
}
use of android.view.animation.AnimationSet in project platform_packages_apps_launcher by android.
the class DeleteZone method createAnimations.
private void createAnimations() {
if (mInAnimation == null) {
mInAnimation = new FastAnimationSet();
final AnimationSet animationSet = mInAnimation;
animationSet.setInterpolator(new AccelerateInterpolator());
animationSet.addAnimation(new AlphaAnimation(0.0f, 1.0f));
if (mOrientation == ORIENTATION_HORIZONTAL) {
animationSet.addAnimation(new TranslateAnimation(Animation.ABSOLUTE, 0.0f, Animation.ABSOLUTE, 0.0f, Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f));
} else {
animationSet.addAnimation(new TranslateAnimation(Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.ABSOLUTE, 0.0f, Animation.ABSOLUTE, 0.0f));
}
animationSet.setDuration(ANIMATION_DURATION);
}
if (mHandleInAnimation == null) {
if (mOrientation == ORIENTATION_HORIZONTAL) {
mHandleInAnimation = new TranslateAnimation(Animation.ABSOLUTE, 0.0f, Animation.ABSOLUTE, 0.0f, Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f);
} else {
mHandleInAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.ABSOLUTE, 0.0f, Animation.ABSOLUTE, 0.0f);
}
mHandleInAnimation.setDuration(ANIMATION_DURATION);
}
if (mOutAnimation == null) {
mOutAnimation = new FastAnimationSet();
final AnimationSet animationSet = mOutAnimation;
animationSet.setInterpolator(new AccelerateInterpolator());
animationSet.addAnimation(new AlphaAnimation(1.0f, 0.0f));
if (mOrientation == ORIENTATION_HORIZONTAL) {
animationSet.addAnimation(new FastTranslateAnimation(Animation.ABSOLUTE, 0.0f, Animation.ABSOLUTE, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 1.0f));
} else {
animationSet.addAnimation(new FastTranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 1.0f, Animation.ABSOLUTE, 0.0f, Animation.ABSOLUTE, 0.0f));
}
animationSet.setDuration(ANIMATION_DURATION);
}
if (mHandleOutAnimation == null) {
if (mOrientation == ORIENTATION_HORIZONTAL) {
mHandleOutAnimation = new FastTranslateAnimation(Animation.ABSOLUTE, 0.0f, Animation.ABSOLUTE, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 1.0f);
} else {
mHandleOutAnimation = new FastTranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 1.0f, Animation.ABSOLUTE, 0.0f, Animation.ABSOLUTE, 0.0f);
}
mHandleOutAnimation.setFillAfter(true);
mHandleOutAnimation.setDuration(ANIMATION_DURATION);
}
}
use of android.view.animation.AnimationSet in project GwellDemo by dxsdyhm.
the class ScreenShotImageView method AnimalStar.
private void AnimalStar() {
final AlphaAnimation alphaAnimation = new AlphaAnimation(0.1f, 1.0f);
alphaAnimation.setDuration(100);
final ScaleAnimation animation = new ScaleAnimation(1.0f, 0.3f, 1.0f, 0.3f, Animation.RELATIVE_TO_SELF, 0.1f, Animation.RELATIVE_TO_SELF, 0.9f);
animation.setDuration(800);
animation.setFillAfter(true);
AnimationSet set = new AnimationSet(false);
set.setFillAfter(true);
set.addAnimation(alphaAnimation);
set.addAnimation(animation);
this.setAnimation(set);
set.start();
set.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
setColorFilter(Color.WHITE);
}
@Override
public void onAnimationEnd(Animation animation) {
if (removeHandler != null) {
removeHandler.sendEmptyMessageDelayed(0, DeleteTime);
}
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
}
use of android.view.animation.AnimationSet in project JustAndroid by chinaltz.
the class AbAnimationUtil method playLandAnimation.
/**
* 跳动-落下动画.
*
* @param view the view
* @param offsetY the offset y
*/
private void playLandAnimation(final View view, final float offsetY) {
float originalY = -offsetY;
float finalY = 0;
AnimationSet animationSet = new AnimationSet(true);
animationSet.addAnimation(new TranslateAnimation(0, 0, originalY, finalY));
animationSet.setDuration(200);
animationSet.setInterpolator(new AccelerateInterpolator());
animationSet.setFillAfter(true);
animationSet.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
//两秒后再调
view.postDelayed(new Runnable() {
@Override
public void run() {
playJumpAnimation(view, offsetY);
}
}, 2000);
}
});
view.startAnimation(animationSet);
}
Aggregations