use of android.view.animation.ScaleAnimation in project android_frameworks_base by crdroidandroid.
the class DragState method createCancelAnimationLocked.
private Animation createCancelAnimationLocked() {
final AnimationSet set = new AnimationSet(false);
set.addAnimation(new ScaleAnimation(1, 0, 1, 0, mThumbOffsetX, mThumbOffsetY));
set.addAnimation(new AlphaAnimation(mOriginalAlpha, 0));
set.setDuration(ANIMATION_DURATION_MS);
set.setInterpolator(mCubicEaseOutInterpolator);
set.initialize(0, 0, 0, 0);
// Will start on the first call to getTransformation.
set.start();
return set;
}
use of android.view.animation.ScaleAnimation in project android_frameworks_base by crdroidandroid.
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 crdroidandroid.
the class AppTransition method createAspectScaledThumbnailFreeformAnimationLocked.
private AnimationSet createAspectScaledThumbnailFreeformAnimationLocked(Rect sourceFrame, Rect destFrame, @Nullable Rect surfaceInsets, boolean enter) {
final float sourceWidth = sourceFrame.width();
final float sourceHeight = sourceFrame.height();
final float destWidth = destFrame.width();
final float destHeight = destFrame.height();
final float scaleH = enter ? sourceWidth / destWidth : destWidth / sourceWidth;
final float scaleV = enter ? sourceHeight / destHeight : destHeight / sourceHeight;
AnimationSet set = new AnimationSet(true);
final int surfaceInsetsH = surfaceInsets == null ? 0 : surfaceInsets.left + surfaceInsets.right;
final int surfaceInsetsV = surfaceInsets == null ? 0 : surfaceInsets.top + surfaceInsets.bottom;
// We want the scaling to happen from the center of the surface. In order to achieve that,
// we need to account for surface insets that will be used to enlarge the surface.
final float scaleHCenter = ((enter ? destWidth : sourceWidth) + surfaceInsetsH) / 2;
final float scaleVCenter = ((enter ? destHeight : sourceHeight) + surfaceInsetsV) / 2;
final ScaleAnimation scale = enter ? new ScaleAnimation(scaleH, 1, scaleV, 1, scaleHCenter, scaleVCenter) : new ScaleAnimation(1, scaleH, 1, scaleV, scaleHCenter, scaleVCenter);
final int sourceHCenter = sourceFrame.left + sourceFrame.width() / 2;
final int sourceVCenter = sourceFrame.top + sourceFrame.height() / 2;
final int destHCenter = destFrame.left + destFrame.width() / 2;
final int destVCenter = destFrame.top + destFrame.height() / 2;
final int fromX = enter ? sourceHCenter - destHCenter : destHCenter - sourceHCenter;
final int fromY = enter ? sourceVCenter - destVCenter : destVCenter - sourceVCenter;
final TranslateAnimation translation = enter ? new TranslateAnimation(fromX, 0, fromY, 0) : new TranslateAnimation(0, fromX, 0, fromY);
set.addAnimation(scale);
set.addAnimation(translation);
final IRemoteCallback callback = mAnimationFinishedCallback;
if (callback != null) {
set.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
mService.mH.obtainMessage(H.DO_ANIMATION_CALLBACK, callback).sendToTarget();
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
}
return set;
}
use of android.view.animation.ScaleAnimation in project Tapad by berict.
the class AnimateHelper method scaleIn.
public void scaleIn(final int id, int touchX, int touchY, final int delay, final long duration, String handlerName, Activity activity) {
final View view = (View) activity.findViewById(id);
float x = touchX / window.getWindowWidthPx(activity);
float y = touchY / window.getWindowHeightPx(activity);
final ScaleAnimation scaleOut = new ScaleAnimation(0, 1, 0, 1, Animation.ABSOLUTE, x, Animation.ABSOLUTE, y);
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 IN 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 IN 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 AnimateHelper method scaleInOverShoot.
public void scaleInOverShoot(final View view, final int delay, final long duration, String handlerName) {
final ScaleAnimation scaleInOverShoot = new ScaleAnimation(0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
view.setVisibility(View.INVISIBLE);
scaleInOverShoot.setInterpolator(new OvershootInterpolator());
Map<String, Handler> handlerCreator = new HashMap<>();
handlerCreator.put(handlerName, new Handler());
handlerCreator.get(handlerName).postDelayed(new Runnable() {
@Override
public void run() {
scaleInOverShoot.setDuration(duration);
view.startAnimation(scaleInOverShoot);
view.setVisibility(View.VISIBLE);
Log.i("AnimateHelper", "scale IN OVERSHOOT effect for " + String.valueOf(duration) + "ms with " + String.valueOf(delay) + "ms delay");
}
}, delay);
}
Aggregations