use of com.nineoldandroids.animation.ValueAnimator in project Carbon by ZieIony.
the class GridLayout method startReveal.
@Override
public Animator startReveal(int x, int y, float startRadius, float finishRadius) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT_WATCH) {
android.animation.Animator circularReveal = ViewAnimationUtils.createCircularReveal(this, x, y, startRadius, finishRadius);
circularReveal.start();
return new Animator() {
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public long getStartDelay() {
return circularReveal.getStartDelay();
}
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public void setStartDelay(long startDelay) {
circularReveal.setStartDelay(startDelay);
}
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public Animator setDuration(long duration) {
circularReveal.setDuration(duration);
return this;
}
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public long getDuration() {
return circularReveal.getDuration();
}
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public void setInterpolator(Interpolator value) {
circularReveal.setInterpolator(value);
}
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public boolean isRunning() {
return circularReveal.isRunning();
}
};
} else {
reveal = new Reveal(x, y, startRadius);
ValueAnimator animator = ValueAnimator.ofFloat(startRadius, finishRadius);
animator.setDuration(Carbon.getDefaultRevealDuration());
animator.addUpdateListener(animation -> {
reveal.radius = (float) animation.getAnimatedValue();
reveal.mask.reset();
reveal.mask.addCircle(reveal.x, reveal.y, Math.max(reveal.radius, 1), Path.Direction.CW);
postInvalidate();
});
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationCancel(Animator animation) {
reveal = null;
}
@Override
public void onAnimationEnd(Animator animation) {
reveal = null;
}
});
animator.start();
return animator;
}
}
use of com.nineoldandroids.animation.ValueAnimator in project Carbon by ZieIony.
the class FlowLayout method startReveal.
@Override
public Animator startReveal(int x, int y, float startRadius, float finishRadius) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT_WATCH) {
android.animation.Animator circularReveal = ViewAnimationUtils.createCircularReveal(this, x, y, startRadius, finishRadius);
circularReveal.start();
return new Animator() {
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public long getStartDelay() {
return circularReveal.getStartDelay();
}
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public void setStartDelay(long startDelay) {
circularReveal.setStartDelay(startDelay);
}
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public Animator setDuration(long duration) {
circularReveal.setDuration(duration);
return this;
}
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public long getDuration() {
return circularReveal.getDuration();
}
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public void setInterpolator(Interpolator value) {
circularReveal.setInterpolator(value);
}
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public boolean isRunning() {
return circularReveal.isRunning();
}
};
} else {
reveal = new Reveal(x, y, startRadius);
ValueAnimator animator = ValueAnimator.ofFloat(startRadius, finishRadius);
animator.setDuration(Carbon.getDefaultRevealDuration());
animator.addUpdateListener(animation -> {
reveal.radius = (float) animation.getAnimatedValue();
reveal.mask.reset();
reveal.mask.addCircle(reveal.x, reveal.y, Math.max(reveal.radius, 1), Path.Direction.CW);
postInvalidate();
});
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationCancel(Animator animation) {
reveal = null;
}
@Override
public void onAnimationEnd(Animator animation) {
reveal = null;
}
});
animator.start();
return animator;
}
}
use of com.nineoldandroids.animation.ValueAnimator in project Carbon by ZieIony.
the class ShareToolbarActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_share_toolbar);
final LinearLayout shareToolbar = (LinearLayout) findViewById(R.id.shareToolbar);
final View root = shareToolbar.getRootView();
findViewById(R.id.shareIcon).setOnClickListener(view -> {
view.setVisibility(View.GONE);
final ValueAnimator animator = ValueAnimator.ofFloat(0, 1);
animator.setInterpolator(new AccelerateInterpolator());
animator.addUpdateListener(animation -> {
float frac = animator.getAnimatedFraction();
float cornerRadius = MathUtils.lerp(shareToolbar.getHeight() / 2.0f, 0, frac);
shareToolbar.setCornerRadius((int) cornerRadius);
float left = MathUtils.lerp(root.getWidth() - shareToolbar.getHeight() - getResources().getDimension(R.dimen.carbon_padding), 0, frac);
float right = MathUtils.lerp(root.getWidth() - getResources().getDimension(R.dimen.carbon_padding), root.getWidth(), frac);
shareToolbar.layout((int) left, shareToolbar.getTop(), (int) right, shareToolbar.getBottom());
shareToolbar.setElevation(frac);
shareToolbar.setBackgroundColor(AnimUtils.lerpColor(frac, 0xff9ACE00, 0xffffffff));
if (shareToolbar.getParent() != null)
((View) shareToolbar.getParent()).postInvalidate();
});
animator.setStartDelay(200);
animator.setDuration(500);
view.setEnabled(false);
animator.start();
final List<View> viewsWithTag = shareToolbar.findViewsWithTag("animate");
view.getHandler().postDelayed(() -> {
for (int i = 0; i < viewsWithTag.size(); i++) {
final int finalI = i;
view.getHandler().postDelayed(() -> viewsWithTag.get(finalI).setVisibility(View.VISIBLE), i * 40);
}
}, 500);
});
}
use of com.nineoldandroids.animation.ValueAnimator in project Carbon by ZieIony.
the class Toolbar method startReveal.
@Override
public Animator startReveal(int x, int y, float startRadius, float finishRadius) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT_WATCH) {
android.animation.Animator circularReveal = ViewAnimationUtils.createCircularReveal(this, x, y, startRadius, finishRadius);
circularReveal.start();
return new Animator() {
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public long getStartDelay() {
return circularReveal.getStartDelay();
}
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public void setStartDelay(long startDelay) {
circularReveal.setStartDelay(startDelay);
}
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public Animator setDuration(long duration) {
circularReveal.setDuration(duration);
return this;
}
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public long getDuration() {
return circularReveal.getDuration();
}
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public void setInterpolator(Interpolator value) {
circularReveal.setInterpolator(value);
}
@Override
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public boolean isRunning() {
return circularReveal.isRunning();
}
};
} else {
reveal = new Reveal(x, y, startRadius);
ValueAnimator animator = ValueAnimator.ofFloat(startRadius, finishRadius);
animator.setDuration(Carbon.getDefaultRevealDuration());
animator.addUpdateListener(animation -> {
reveal.radius = (float) animation.getAnimatedValue();
reveal.mask.reset();
reveal.mask.addCircle(reveal.x, reveal.y, Math.max(reveal.radius, 1), Path.Direction.CW);
postInvalidate();
});
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationCancel(Animator animation) {
reveal = null;
}
@Override
public void onAnimationEnd(Animator animation) {
reveal = null;
}
});
animator.start();
return animator;
}
}
use of com.nineoldandroids.animation.ValueAnimator in project ElasticDownload by Tibolte.
the class PathAnimatorInflater method loadAnimator.
/**
* Creates a new animation whose parameters come from the specified context
* and attributes set.
*
* @param res The resources
* @param attrs The set of attributes holding the animation parameters
* @param anim Null if this is a ValueAnimator, otherwise this is an
* ObjectAnimator
*/
private static ValueAnimator loadAnimator(Context c, Resources res, Resources.Theme theme, AttributeSet attrs, ValueAnimator anim, float pathErrorScale) throws Resources.NotFoundException {
TypedArray arrayAnimator = null;
TypedArray arrayObjectAnimator = null;
if (theme != null) {
arrayAnimator = theme.obtainStyledAttributes(attrs, R.styleable.Animator, 0, 0);
} else {
arrayAnimator = res.obtainAttributes(attrs, R.styleable.Animator);
}
// If anim is not null, then it is an object animator.
if (anim != null) {
if (theme != null) {
arrayObjectAnimator = theme.obtainStyledAttributes(attrs, R.styleable.PropertyAnimator, 0, 0);
} else {
arrayObjectAnimator = res.obtainAttributes(attrs, R.styleable.PropertyAnimator);
}
}
if (anim == null) {
anim = new ValueAnimator();
}
parseAnimatorFromTypeArray(anim, arrayAnimator, arrayObjectAnimator);
final int resId = arrayAnimator.getResourceId(R.styleable.Animator_android_interpolator, 0);
if (resId > 0) {
anim.setInterpolator(AnimationUtils.loadInterpolator(c, resId));
}
arrayAnimator.recycle();
if (arrayObjectAnimator != null) {
arrayObjectAnimator.recycle();
}
return anim;
}
Aggregations