use of android.animation.AnimatorListenerAdapter in project JJSearchViewAnim by android-cjj.
the class JJBaseController method startSearchViewAnim.
public ValueAnimator startSearchViewAnim(float startF, float endF, long time, final PathMeasure pathMeasure) {
ValueAnimator valueAnimator = ValueAnimator.ofFloat(startF, endF);
valueAnimator.setDuration(time);
valueAnimator.setInterpolator(new LinearInterpolator());
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
mPro = (float) valueAnimator.getAnimatedValue();
if (null != pathMeasure)
pathMeasure.getPosTan(mPro, mPos, null);
getSearchView().invalidate();
}
});
valueAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
}
});
if (!valueAnimator.isRunning()) {
valueAnimator.start();
}
mPro = 0;
return valueAnimator;
}
use of android.animation.AnimatorListenerAdapter in project android-demos by novoda.
the class VisibilityController method setVisible.
boolean setVisible(final boolean visible, boolean animated) {
if (isVisible() == visible) {
return false;
}
mVisible = visible;
if (animated) {
float toAlpha = visible ? 1.0f : 0.0f;
ObjectAnimator mAnimator = ObjectAnimator.ofFloat(mView, "Alpha", 1 - toAlpha, toAlpha);
mAnimator.setDuration(mAnimationDuration).addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animator) {
if (visible) {
setViewVisible(true);
}
}
@Override
public void onAnimationEnd(Animator animator) {
if (!visible) {
setViewVisible(false);
}
}
});
mAnimator.start();
} else {
setViewVisible(visible);
}
return true;
}
use of android.animation.AnimatorListenerAdapter in project weiciyuan by qii.
the class GalleryActivity method animateClose.
private void animateClose(PhotoView imageView) {
currentViewPositionLayout.setVisibility(View.INVISIBLE);
animationView.setImageDrawable(imageView.getDrawable());
pager.setVisibility(View.INVISIBLE);
final Rect startBounds = rect;
final Rect finalBounds = new Rect();
final Point globalOffset = new Point();
animationView.getGlobalVisibleRect(finalBounds, globalOffset);
startBounds.offset(-globalOffset.x, -globalOffset.y);
finalBounds.offset(-globalOffset.x, -globalOffset.y);
float startScale;
if ((float) finalBounds.width() / finalBounds.height() > (float) startBounds.width() / startBounds.height()) {
// Extend start bounds horizontally
startScale = (float) startBounds.height() / finalBounds.height();
float startWidth = startScale * finalBounds.width();
float deltaWidth = (startWidth - startBounds.width()) / 2;
startBounds.left -= deltaWidth;
startBounds.right += deltaWidth;
} else {
// Extend start bounds vertically
startScale = (float) startBounds.width() / finalBounds.width();
float startHeight = startScale * finalBounds.height();
float deltaHeight = (startHeight - startBounds.height()) / 2;
startBounds.top -= deltaHeight;
startBounds.bottom += deltaHeight;
}
animationView.setPivotX(0f);
animationView.setPivotY(0f);
final float startScaleFinal = startScale;
animationView.animate().setInterpolator(new DecelerateInterpolator()).x(startBounds.left).y(startBounds.top).scaleY(startScaleFinal).scaleX(startScaleFinal).setDuration(300).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
GalleryActivity.this.finish();
overridePendingTransition(0, 0);
}
}).start();
}
use of android.animation.AnimatorListenerAdapter in project weiciyuan by qii.
the class GalleryAnimationActivity method onBackPressed.
@Override
public void onBackPressed() {
ContainerFragment fragment = fragmentMap.get(pager.getCurrentItem());
if (fragment != null && fragment.canAnimateCloseActivity()) {
backgroundColor = new ColorDrawable(Color.BLACK);
ObjectAnimator bgAnim = ObjectAnimator.ofInt(backgroundColor, "alpha", 0);
bgAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
background.setBackground(backgroundColor);
}
});
bgAnim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
GalleryAnimationActivity.super.finish();
overridePendingTransition(-1, -1);
}
});
fragment.animationExit(bgAnim);
} else {
super.onBackPressed();
}
}
use of android.animation.AnimatorListenerAdapter in project platform_frameworks_base by android.
the class LockPatternView method startLineEndAnimation.
private void startLineEndAnimation(final CellState state, final float startX, final float startY, final float targetX, final float targetY) {
ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, 1);
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float t = (float) animation.getAnimatedValue();
state.lineEndX = (1 - t) * startX + t * targetX;
state.lineEndY = (1 - t) * startY + t * targetY;
invalidate();
}
});
valueAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
state.lineAnimator = null;
}
});
valueAnimator.setInterpolator(mFastOutSlowInInterpolator);
valueAnimator.setDuration(100);
valueAnimator.start();
state.lineAnimator = valueAnimator;
}
Aggregations