use of android.view.animation.Interpolator 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 android.view.animation.Interpolator 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 android.view.animation.Interpolator 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 android.view.animation.Interpolator in project android_frameworks_base by ParanoidAndroid.
the class GlobalScreenshot method createScreenshotDropInAnimation.
private ValueAnimator createScreenshotDropInAnimation() {
final float flashPeakDurationPct = ((float) (SCREENSHOT_FLASH_TO_PEAK_DURATION) / SCREENSHOT_DROP_IN_DURATION);
final float flashDurationPct = 2f * flashPeakDurationPct;
final Interpolator flashAlphaInterpolator = new Interpolator() {
@Override
public float getInterpolation(float x) {
// Flash the flash view in and out quickly
if (x <= flashDurationPct) {
return (float) Math.sin(Math.PI * (x / flashDurationPct));
}
return 0;
}
};
final Interpolator scaleInterpolator = new Interpolator() {
@Override
public float getInterpolation(float x) {
// We start scaling when the flash is at it's peak
if (x < flashPeakDurationPct) {
return 0;
}
return (x - flashDurationPct) / (1f - flashDurationPct);
}
};
ValueAnimator anim = ValueAnimator.ofFloat(0f, 1f);
anim.setDuration(SCREENSHOT_DROP_IN_DURATION);
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
mBackgroundView.setAlpha(0f);
mBackgroundView.setVisibility(View.VISIBLE);
mScreenshotView.setAlpha(0f);
mScreenshotView.setTranslationX(0f);
mScreenshotView.setTranslationY(0f);
mScreenshotView.setScaleX(SCREENSHOT_SCALE + mBgPaddingScale);
mScreenshotView.setScaleY(SCREENSHOT_SCALE + mBgPaddingScale);
mScreenshotView.setVisibility(View.VISIBLE);
mScreenshotFlash.setAlpha(0f);
mScreenshotFlash.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationEnd(android.animation.Animator animation) {
mScreenshotFlash.setVisibility(View.GONE);
}
});
anim.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float t = (Float) animation.getAnimatedValue();
float scaleT = (SCREENSHOT_SCALE + mBgPaddingScale) - scaleInterpolator.getInterpolation(t) * (SCREENSHOT_SCALE - SCREENSHOT_DROP_IN_MIN_SCALE);
mBackgroundView.setAlpha(scaleInterpolator.getInterpolation(t) * BACKGROUND_ALPHA);
mScreenshotView.setAlpha(t);
mScreenshotView.setScaleX(scaleT);
mScreenshotView.setScaleY(scaleT);
mScreenshotFlash.setAlpha(flashAlphaInterpolator.getInterpolation(t));
}
});
return anim;
}
use of android.view.animation.Interpolator in project UltimateAndroid by cymcsg.
the class PullDoorView method setupView.
@SuppressLint("NewApi")
private void setupView() {
// 这个Interpolator你可以设置别的 我这里选择的是有弹跳效果的Interpolator
Interpolator polator = new BounceInterpolator();
mScroller = new Scroller(mContext, polator);
// 获取屏幕分辨率
WindowManager wm = (WindowManager) (mContext.getSystemService(Context.WINDOW_SERVICE));
DisplayMetrics dm = new DisplayMetrics();
wm.getDefaultDisplay().getMetrics(dm);
mScreenHeigh = dm.heightPixels;
mScreenWidth = dm.widthPixels;
// 这里你一定要设置成透明背景,不然会影响你看到底层布局
this.setBackgroundColor(Color.argb(0, 0, 0, 0));
mImgView = new ImageView(mContext);
mImgView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
// 填充整个屏幕
mImgView.setScaleType(ImageView.ScaleType.FIT_XY);
// 默认背景
mImgView.setImageResource(R.drawable.test);
addView(mImgView);
}
Aggregations