use of android.animation.AnimatorSet in project kickmaterial by byoutline.
the class AnimatorUtils method getScaleAnimator.
public static AnimatorSet getScaleAnimator(View view, float startScale, float endScale) {
AnimatorSet set = new AnimatorSet();
ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(view, View.SCALE_X, startScale, endScale);
ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(view, View.SCALE_Y, startScale, endScale);
set.playTogether(scaleXAnimator, scaleYAnimator);
return set;
}
use of android.animation.AnimatorSet in project kickmaterial by byoutline.
the class CircleTransition method createAnimator.
@Override
public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues, final TransitionValues endValues) {
if (startValues == null || endValues == null) {
return null;
}
Rect startBounds = (Rect) startValues.values.get(PROPERTY_BOUNDS);
Rect endBounds = (Rect) endValues.values.get(PROPERTY_BOUNDS);
boolean boundsEqual = startBounds == null || endBounds == null || startBounds.equals(endBounds);
if (boundsEqual) {
return null;
}
int[] sceneRootLoc = new int[2];
sceneRoot.getLocationInWindow(sceneRootLoc);
int[] startLoc = (int[]) startValues.values.get(PROPERTY_POSITION);
final View startView = getStartView(sceneRoot, startValues, sceneRootLoc, startLoc);
final View endView = endValues.view;
endView.setAlpha(0f);
Path circlePath = getMovePath(endValues, startView, sceneRootLoc, startLoc, endView);
Animator circleAnimator = ObjectAnimator.ofFloat(startView, View.TRANSLATION_X, View.TRANSLATION_Y, circlePath);
circleAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
startView.setVisibility(View.INVISIBLE);
endView.setAlpha(1f);
sceneRoot.getOverlay().remove(startView);
}
});
AnimatorSet moveSet = new AnimatorSet();
float scaleRatio = ((float) endView.getWidth()) / startView.getWidth();
ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(startView, View.SCALE_X, 1, scaleRatio);
ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(startView, View.SCALE_Y, 1, scaleRatio);
moveSet.playTogether(circleAnimator, scaleXAnimator, scaleYAnimator);
return moveSet;
}
use of android.animation.AnimatorSet in project cw-omnibus by commonsguy.
the class AsyncDemoFragment method changeMenuIconAnimation.
// based on https://goo.gl/3IUM8K
private void changeMenuIconAnimation(final FloatingActionMenu menu) {
AnimatorSet set = new AnimatorSet();
final ImageView v = menu.getMenuIconView();
ObjectAnimator scaleOutX = ObjectAnimator.ofFloat(v, "scaleX", 1.0f, 0.2f);
ObjectAnimator scaleOutY = ObjectAnimator.ofFloat(v, "scaleY", 1.0f, 0.2f);
ObjectAnimator scaleInX = ObjectAnimator.ofFloat(v, "scaleX", 0.2f, 1.0f);
ObjectAnimator scaleInY = ObjectAnimator.ofFloat(v, "scaleY", 0.2f, 1.0f);
scaleOutX.setDuration(50);
scaleOutY.setDuration(50);
scaleInX.setDuration(150);
scaleInY.setDuration(150);
scaleInX.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
v.setImageResource(menu.isOpened() ? R.drawable.ic_action_settings : R.drawable.ic_close);
}
});
set.play(scaleOutX).with(scaleOutY);
set.play(scaleInX).with(scaleInY).after(scaleOutX);
set.setInterpolator(new OvershootInterpolator(2));
menu.setIconToggleAnimatorSet(set);
}
use of android.animation.AnimatorSet in project kickmaterial by byoutline.
the class CategoriesListActivity method runFinishAnimation.
private void runFinishAnimation(Runnable finishAction) {
if (summaryScrolledValue > 0) {
binding.categoriesRv.smoothScrollToPosition(0);
}
ViewUtils.showView(binding.selectCategoryTv, false);
ObjectAnimator imageFade = ObjectAnimator.ofFloat(binding.selectedCategoryIv, View.ALPHA, 1, 0);
AnimatorSet set = new AnimatorSet();
AnimatorSet closeButtonScale = AnimatorUtils.getScaleAnimator(binding.closeCategoriesIv, 1, 0.1f);
set.playTogether(closeButtonScale, imageFade);
set.setDuration(FINISH_ANIMATION_DURATION);
set.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (revealAnimation != null) {
revealAnimation.cancel();
}
ViewUtils.showView(binding.categoryCircleRevealIv, false);
binding.closeCategoriesIv.setScaleX(0);
binding.closeCategoriesIv.setScaleY(0);
finishAction.run();
}
});
binding.categoriesRv.startAnimation(LUtils.loadAnimationWithLInterpolator(getApplicationContext(), R.anim.slide_to_bottom));
set.start();
}
use of android.animation.AnimatorSet in project nmid-headline by miao1007.
the class ImagesFeedAdapter method updateHeartButton.
private void updateHeartButton(final StreamViewHolder holder, boolean animated, final boolean isLike) {
if (animated) {
if (!likeAnimations.containsKey(holder)) {
AnimatorSet animatorSet = new AnimatorSet();
likeAnimations.put(holder, animatorSet);
ObjectAnimator rotationAnim = ObjectAnimator.ofFloat(holder.mBtn_like, "rotation", 0f, 360f);
rotationAnim.setDuration(300);
rotationAnim.setInterpolator(ACCELERATE_INTERPOLATOR);
ObjectAnimator bounceAnimX = ObjectAnimator.ofFloat(holder.mBtn_like, "scaleX", 0.2f, 1f);
bounceAnimX.setDuration(300);
bounceAnimX.setInterpolator(OVERSHOOT_INTERPOLATOR);
ObjectAnimator bounceAnimY = ObjectAnimator.ofFloat(holder.mBtn_like, "scaleY", 0.2f, 1f);
bounceAnimY.setDuration(300);
bounceAnimY.setInterpolator(OVERSHOOT_INTERPOLATOR);
bounceAnimY.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
if (isLike) {
holder.mBtn_like.setImageResource(R.drawable.ic_heart_red);
} else {
holder.mBtn_like.setImageResource(R.drawable.ic_heart_outline_grey);
}
}
});
animatorSet.play(rotationAnim);
animatorSet.play(bounceAnimX).with(bounceAnimY).after(rotationAnim);
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
resetLikeAnimationState(holder);
}
});
animatorSet.start();
}
} else {
if (likedPositions.contains(holder.getPosition())) {
holder.mBtn_like.setImageResource(R.drawable.ic_heart_red);
} else {
holder.mBtn_like.setImageResource(R.drawable.ic_heart_outline_grey);
}
}
}
Aggregations