use of android.view.animation.ScaleAnimation in project android_frameworks_base by ResurrectionRemix.
the class AppTransition method createThumbnailScaleAnimationLocked.
/**
* This animation runs for the thumbnail that gets cross faded with the enter/exit activity
* when a thumbnail is specified with the pending animation override.
*/
Animation createThumbnailScaleAnimationLocked(int appWidth, int appHeight, int transit, Bitmap thumbnailHeader) {
Animation a;
getDefaultNextAppTransitionStartRect(mTmpRect);
final int thumbWidthI = thumbnailHeader.getWidth();
final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
final int thumbHeightI = thumbnailHeader.getHeight();
final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1;
if (mNextAppTransitionScaleUp) {
// Animation for the thumbnail zooming from its initial size to the full screen
float scaleW = appWidth / thumbWidth;
float scaleH = appHeight / thumbHeight;
Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH, computePivot(mTmpRect.left, 1 / scaleW), computePivot(mTmpRect.top, 1 / scaleH));
scale.setInterpolator(mDecelerateInterpolator);
Animation alpha = new AlphaAnimation(1, 0);
alpha.setInterpolator(mThumbnailFadeOutInterpolator);
// This AnimationSet uses the Interpolators assigned above.
AnimationSet set = new AnimationSet(false);
set.addAnimation(scale);
set.addAnimation(alpha);
a = set;
} else {
// Animation for the thumbnail zooming down from the full screen to its final size
float scaleW = appWidth / thumbWidth;
float scaleH = appHeight / thumbHeight;
a = new ScaleAnimation(scaleW, 1, scaleH, 1, computePivot(mTmpRect.left, 1 / scaleW), computePivot(mTmpRect.top, 1 / scaleH));
}
return prepareThumbnailAnimation(a, appWidth, appHeight, transit);
}
use of android.view.animation.ScaleAnimation in project android_frameworks_base by ResurrectionRemix.
the class AppTransition method createScaleUpAnimationLocked.
private Animation createScaleUpAnimationLocked(int transit, boolean enter, Rect containingFrame) {
Animation a;
getDefaultNextAppTransitionStartRect(mTmpRect);
final int appWidth = containingFrame.width();
final int appHeight = containingFrame.height();
if (enter) {
// Entering app zooms out from the center of the initial rect.
float scaleW = mTmpRect.width() / (float) appWidth;
float scaleH = mTmpRect.height() / (float) appHeight;
Animation scale = new ScaleAnimation(scaleW, 1, scaleH, 1, computePivot(mTmpRect.left, scaleW), computePivot(mTmpRect.top, scaleH));
scale.setInterpolator(mDecelerateInterpolator);
Animation alpha = new AlphaAnimation(0, 1);
alpha.setInterpolator(mThumbnailFadeOutInterpolator);
AnimationSet set = new AnimationSet(false);
set.addAnimation(scale);
set.addAnimation(alpha);
set.setDetachWallpaper(true);
a = set;
} else 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.
a = new AlphaAnimation(1, 0);
a.setDetachWallpaper(true);
} else {
// For normal animations, the exiting element just holds in place.
a = new AlphaAnimation(1, 1);
}
// Pick the desired duration. If this is an inter-activity transition,
// it is the standard duration for that. Otherwise we use the longer
// task transition duration.
final long duration;
switch(transit) {
case TRANSIT_ACTIVITY_OPEN:
case TRANSIT_ACTIVITY_CLOSE:
duration = mConfigShortAnimTime;
break;
default:
duration = DEFAULT_APP_TRANSITION_DURATION;
break;
}
a.setDuration(duration);
a.setFillAfter(true);
a.setInterpolator(mDecelerateInterpolator);
a.initialize(appWidth, appHeight, appWidth, appHeight);
return a;
}
use of android.view.animation.ScaleAnimation in project android_frameworks_base by ResurrectionRemix.
the class AppTransition method createRelaunchAnimation.
private Animation createRelaunchAnimation(Rect containingFrame, Rect contentInsets) {
getDefaultNextAppTransitionStartRect(mTmpFromClipRect);
final int left = mTmpFromClipRect.left;
final int top = mTmpFromClipRect.top;
mTmpFromClipRect.offset(-left, -top);
// TODO: Isn't that strange that we ignore exact position of the containingFrame?
mTmpToClipRect.set(0, 0, containingFrame.width(), containingFrame.height());
AnimationSet set = new AnimationSet(true);
float fromWidth = mTmpFromClipRect.width();
float toWidth = mTmpToClipRect.width();
float fromHeight = mTmpFromClipRect.height();
// While the window might span the whole display, the actual content will be cropped to the
// system decoration frame, for example when the window is docked. We need to take into
// account the visible height when constructing the animation.
float toHeight = mTmpToClipRect.height() - contentInsets.top - contentInsets.bottom;
int translateAdjustment = 0;
if (fromWidth <= toWidth && fromHeight <= toHeight) {
// The final window is larger in both dimensions than current window (e.g. we are
// maximizing), so we can simply unclip the new window and there will be no disappearing
// frame.
set.addAnimation(new ClipRectAnimation(mTmpFromClipRect, mTmpToClipRect));
} else {
// The disappearing window has one larger dimension. We need to apply scaling, so the
// first frame of the entry animation matches the old window.
set.addAnimation(new ScaleAnimation(fromWidth / toWidth, 1, fromHeight / toHeight, 1));
// We might not be going exactly full screen, but instead be aligned under the status
// bar using cropping. We still need to account for the cropped part, which will also
// be scaled.
translateAdjustment = (int) (contentInsets.top * fromHeight / toHeight);
}
// We animate the translation from the old position of the removed window, to the new
// position of the added window. The latter might not be full screen, for example docked for
// docked windows.
TranslateAnimation translate = new TranslateAnimation(left - containingFrame.left, 0, top - containingFrame.top - translateAdjustment, 0);
set.addAnimation(translate);
set.setDuration(DEFAULT_APP_TRANSITION_DURATION);
set.setZAdjustment(Animation.ZORDER_TOP);
return set;
}
use of android.view.animation.ScaleAnimation in project Tapad by berict.
the class AnimateHelper method scaleOut.
// Scale Animations
public void scaleOut(final View view, final int delay, final long duration, String handlerName) {
final ScaleAnimation scaleOut = new ScaleAnimation(1, 0, 1, 0, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
scaleOut.setInterpolator(new AccelerateDecelerateInterpolator());
Map<String, Handler> handlerCreator = new HashMap<>();
handlerCreator.put(handlerName, new Handler());
if (delay > 0) {
handlerCreator.get(handlerName).postDelayed(new Runnable() {
@Override
public void run() {
view.setVisibility(View.VISIBLE);
scaleOut.setDuration(duration);
view.startAnimation(scaleOut);
Log.i("AnimateHelper", "scale OUT effect for " + String.valueOf(duration) + "ms with " + String.valueOf(delay) + "ms delay");
}
}, delay);
} else {
view.setVisibility(View.VISIBLE);
scaleOut.setDuration(duration);
view.startAnimation(scaleOut);
Log.i("AnimateHelper", "scale OUT effect for " + String.valueOf(duration) + "ms with " + String.valueOf(delay) + "ms delay");
}
handlerCreator.get(handlerName).postDelayed(new Runnable() {
@Override
public void run() {
view.setVisibility(View.GONE);
}
}, delay + 10);
}
use of android.view.animation.ScaleAnimation in project Tapad by berict.
the class TutorialHelper method playAnimation.
void playAnimation(final int viewId, ScaleAnimation animation, final Activity activity) {
View view = window.getView(R.id.base_tutorial, activity).findViewById(viewId);
animation.setInterpolator(new AccelerateDecelerateInterpolator());
animation.setDuration(300);
view.startAnimation(animation);
view.setVisibility(View.VISIBLE);
animation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
anim.fadeOut(viewId, 0, 200, activity);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
}
Aggregations