use of android.view.animation.Animation in project ArcMenu by daCapricorn.
the class ArcLayout method createExpandAnimation.
private static Animation createExpandAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta, long startOffset, long duration, Interpolator interpolator) {
Animation animation = new RotateAndTranslateAnimation(0, toXDelta, 0, toYDelta, 0, 720);
animation.setStartOffset(startOffset);
animation.setDuration(duration);
animation.setInterpolator(interpolator);
animation.setFillAfter(true);
return animation;
}
use of android.view.animation.Animation in project ArcMenu by daCapricorn.
the class ArcLayout method createShrinkAnimation.
private static Animation createShrinkAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta, long startOffset, long duration, Interpolator interpolator) {
AnimationSet animationSet = new AnimationSet(false);
animationSet.setFillAfter(true);
final long preDuration = duration / 2;
Animation rotateAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
rotateAnimation.setStartOffset(startOffset);
rotateAnimation.setDuration(preDuration);
rotateAnimation.setInterpolator(new LinearInterpolator());
rotateAnimation.setFillAfter(true);
animationSet.addAnimation(rotateAnimation);
Animation translateAnimation = new RotateAndTranslateAnimation(0, toXDelta, 0, toYDelta, 360, 720);
translateAnimation.setStartOffset(startOffset + preDuration);
translateAnimation.setDuration(duration - preDuration);
translateAnimation.setInterpolator(interpolator);
translateAnimation.setFillAfter(true);
animationSet.addAnimation(translateAnimation);
return animationSet;
}
use of android.view.animation.Animation in project ArcMenu by daCapricorn.
the class ArcMenu method getItemClickListener.
private OnClickListener getItemClickListener(final OnClickListener listener) {
return new OnClickListener() {
@Override
public void onClick(final View viewClicked) {
Animation animation = bindItemAnimation(viewClicked, true, 400);
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
postDelayed(new Runnable() {
@Override
public void run() {
itemDidDisappear();
}
}, 0);
}
});
final int itemCount = mArcLayout.getChildCount();
for (int i = 0; i < itemCount; i++) {
View item = mArcLayout.getChildAt(i);
if (viewClicked != item) {
bindItemAnimation(item, false, 300);
}
}
mArcLayout.invalidate();
mHintView.startAnimation(createHintSwitchAnimation(true));
if (listener != null) {
listener.onClick(viewClicked);
}
}
};
}
use of android.view.animation.Animation in project ArcMenu by daCapricorn.
the class ArcMenu method createHintSwitchAnimation.
private static Animation createHintSwitchAnimation(final boolean expanded) {
Animation animation = new RotateAnimation(expanded ? 45 : 0, expanded ? 0 : 45, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
animation.setStartOffset(0);
animation.setDuration(100);
animation.setInterpolator(new DecelerateInterpolator());
animation.setFillAfter(true);
return animation;
}
use of android.view.animation.Animation in project ArcMenu by daCapricorn.
the class RayLayout method bindChildAnimation.
private void bindChildAnimation(final View child, final int index, final long duration) {
final boolean expanded = mExpanded;
final int childCount = getChildCount();
Rect frame = computeChildFrame(!expanded, mLeftHolderWidth, index, mChildGap, mChildSize);
final int toXDelta = frame.left - child.getLeft();
final int toYDelta = frame.top - child.getTop();
Interpolator interpolator = mExpanded ? new AccelerateInterpolator() : new OvershootInterpolator(1.5f);
final long startOffset = computeStartOffset(childCount, mExpanded, index, 0.1f, duration, interpolator);
Animation animation = mExpanded ? createShrinkAnimation(0, toXDelta, 0, toYDelta, startOffset, duration, interpolator) : createExpandAnimation(0, toXDelta, 0, toYDelta, startOffset, duration, interpolator);
final boolean isLast = getTransformedIndex(expanded, childCount, index) == childCount - 1;
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
if (isLast) {
postDelayed(new Runnable() {
@Override
public void run() {
onAllAnimationsEnd();
}
}, 0);
}
}
});
child.setAnimation(animation);
}
Aggregations