Here are the examples of the java api android.animation.AnimatorSet.setInterpolator() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
307 Examples
19
Source : ModeOptions.java
with Apache License 2.0
from Yuloran
with Apache License 2.0
from Yuloran
private void setupAnimators() {
if (mVisibleAnimator != null) {
mVisibleAnimator.end();
}
if (mHiddenAnimator != null) {
mHiddenAnimator.end();
}
final float fullSize = (mIsPortrait ? (float) getWidth() : (float) getHeight());
// show
{
final ValueAnimator radiusAnimator = ValueAnimator.ofFloat(mAnimateFrom.width() / 2.0f, fullSize - mAnimateFrom.width() / 2.0f);
radiusAnimator.setDuration(RADIUS_ANIMATION_TIME);
radiusAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mRadius = (Float) animation.getAnimatedValue();
mDrawCircle = true;
mFill = false;
}
});
radiusAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mDrawCircle = false;
mFill = true;
}
});
final ValueAnimator alphaAnimator = ValueAnimator.ofFloat(0.0f, 1.0f);
alphaAnimator.setDuration(SHOW_ALPHA_ANIMATION_TIME);
alphaAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mActiveBar.setAlpha((Float) animation.getAnimatedValue());
}
});
alphaAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mActiveBar.setAlpha(1.0f);
}
});
final int deltaX = getResources().getDimensionPixelSize(R.dimen.mode_options_buttons_anim_delta_x);
int childCount = mActiveBar.getChildCount();
ArrayList<Animator> paddingAnimators = new ArrayList<Animator>();
for (int i = 0; i < childCount; i++) {
final View button;
if (mIsPortrait) {
button = mActiveBar.getChildAt(i);
} else {
button = mActiveBar.getChildAt(childCount - 1 - i);
}
final ValueAnimator paddingAnimator = ValueAnimator.ofFloat(deltaX * (childCount - i), 0.0f);
paddingAnimator.setDuration(PADDING_ANIMATION_TIME);
paddingAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
if (mIsPortrait) {
button.setTranslationX((Float) animation.getAnimatedValue());
} else {
button.setTranslationY(-((Float) animation.getAnimatedValue()));
}
invalidate();
}
});
paddingAnimators.add(paddingAnimator);
}
AnimatorSet paddingAnimatorSet = new AnimatorSet();
paddingAnimatorSet.playTogether(paddingAnimators);
mVisibleAnimator = new AnimatorSet();
mVisibleAnimator.setInterpolator(Gusterpolator.INSTANCE);
mVisibleAnimator.playTogether(radiusAnimator, alphaAnimator, paddingAnimatorSet);
}
// hide
{
final ValueAnimator radiusAnimator = ValueAnimator.ofFloat(fullSize - mAnimateFrom.width() / 2.0f, mAnimateFrom.width() / 2.0f);
radiusAnimator.setDuration(RADIUS_ANIMATION_TIME);
radiusAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mRadius = (Float) animation.getAnimatedValue();
mDrawCircle = true;
mFill = false;
invalidate();
}
});
radiusAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (mViewToShowHide != null) {
mViewToShowHide.setVisibility(View.VISIBLE);
mDrawCircle = false;
mFill = false;
invalidate();
}
}
});
final ValueAnimator alphaAnimator = ValueAnimator.ofFloat(1.0f, 0.0f);
alphaAnimator.setDuration(HIDE_ALPHA_ANIMATION_TIME);
alphaAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mActiveBar.setAlpha((Float) animation.getAnimatedValue());
invalidate();
}
});
alphaAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
setVisibility(View.INVISIBLE);
if (mActiveBar != mMainBar) {
mActiveBar.setAlpha(1.0f);
mActiveBar.setVisibility(View.INVISIBLE);
}
mMainBar.setAlpha(1.0f);
mMainBar.setVisibility(View.VISIBLE);
mActiveBar = mMainBar;
invalidate();
}
});
mHiddenAnimator = new AnimatorSet();
mHiddenAnimator.setInterpolator(Gusterpolator.INSTANCE);
mHiddenAnimator.playTogether(radiusAnimator, alphaAnimator);
}
}
19
Source : ExpandableLinearLayout.java
with Apache License 2.0
from xujiaji
with Apache License 2.0
from xujiaji
private void animateHeight(final View view, final int targetHeight) {
if (animatorSet == null) {
animatorSet = new AnimatorSet();
animatorSet.setInterpolator(interpolator);
animatorSet.setDuration(duration);
}
final LayoutParams lp = (LayoutParams) view.getLayoutParams();
lp.weight = 0;
int height = view.getHeight();
ValueAnimator animator = ValueAnimator.ofInt(height, targetHeight);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
view.getLayoutParams().height = (Integer) valueAnimator.getAnimatedValue();
view.requestLayout();
if (listener != null) {
float fraction = targetHeight == 0 ? 1 - valueAnimator.getAnimatedFraction() : valueAnimator.getAnimatedFraction();
listener.onExpansionUpdate(fraction);
}
}
});
animator.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
view.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationEnd(Animator animator) {
if (targetHeight == 0) {
view.setVisibility(GONE);
} else {
lp.height = lp.originalHeight;
lp.weight = lp.originalWeight;
}
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
});
animatorSet.playTogether(animator);
}
19
Source : EditTextBoldCursor.java
with GNU General Public License v2.0
from TelePlusDev
with GNU General Public License v2.0
from TelePlusDev
private void checkHeaderVisibility(boolean animated) {
boolean newHintHeader = transformHintToHeader && (isFocused() || getText().length() > 0);
if (currentDrawHintAsHeader != newHintHeader) {
if (headerTransformAnimation != null) {
headerTransformAnimation.cancel();
headerTransformAnimation = null;
}
currentDrawHintAsHeader = newHintHeader;
if (animated) {
headerTransformAnimation = new AnimatorSet();
headerTransformAnimation.playTogether(ObjectAnimator.ofFloat(this, "headerAnimationProgress", newHintHeader ? 1.0f : 0.0f));
headerTransformAnimation.setDuration(200);
headerTransformAnimation.setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT);
headerTransformAnimation.start();
} else {
headerAnimationProgress = newHintHeader ? 1.0f : 0.0f;
}
invalidate();
}
}
19
Source : MusicalNoteLayout.java
with Apache License 2.0
from TaoPaox
with Apache License 2.0
from TaoPaox
private Animator getFinalAnimator(View target) {
AnimatorSet set = getEnterAnimator(target);
ValueAnimator bezierValueAnimator = getBezierValueAnimator(target);
AnimatorSet finalSet = new AnimatorSet();
finalSet.playTogether(set, bezierValueAnimator);
finalSet.setInterpolator(new AccelerateInterpolator());
finalSet.setTarget(target);
return finalSet;
}
19
Source : CircleIndexView.java
with Apache License 2.0
from Squirtle12
with Apache License 2.0
from Squirtle12
/**
* @param value 空气质量数值
* @param middleText 空气质量(良)
*/
public void updateIndex(int value, String middleText) {
setMiddleText(middleText);
invalidate();
// 当前角度
float inSweepAngle = sweepAngle * value / 500;
// 角度由0f到当前角度变化
ValueAnimator angleAnim = ValueAnimator.ofFloat(0f, inSweepAngle);
// 动画持续时间
angleAnim.setDuration(getDuration());
// 数值由0到value变化
ValueAnimator valueAnim = ValueAnimator.ofInt(0, value);
valueAnim.setDuration(getDuration());
// 注册监听器
angleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public // 当angleAnim变化回调/
void onAnimationUpdate(ValueAnimator valueAnimator) {
float currentValue = (float) valueAnimator.getAnimatedValue();
// 将当前的角度值赋给inSweepAngle
setInSweepAngle(currentValue);
// 通知view改变,调用这个函数后,会返回到onDraw();
invalidate();
}
});
valueAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
int currentValue = (int) valueAnimator.getAnimatedValue();
setIndexValue(currentValue);
invalidate();
}
});
// 让两个动画同时进行。
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.setInterpolator(new DecelerateInterpolator());
animatorSet.setStartDelay(150);
animatorSet.playTogether(angleAnim, valueAnim);
animatorSet.start();
}
19
Source : FloatingActionMenu.java
with Apache License 2.0
from sougata-chatterjee
with Apache License 2.0
from sougata-chatterjee
/**
* Sets the {@link android.view.animation.Interpolator} for <b>FloatingActionButton's</b> icon animation.
*
* @param interpolator the Interpolator to be used in animation
*/
public void setIconAnimationInterpolator(Interpolator interpolator) {
mOpenAnimatorSet.setInterpolator(interpolator);
mCloseAnimatorSet.setInterpolator(interpolator);
}
19
Source : FloatingActionMenu.java
with Apache License 2.0
from sougata-chatterjee
with Apache License 2.0
from sougata-chatterjee
private void createDefaultIconAnimation() {
float collapseAngle;
float expandAngle;
if (mOpenDirection == OPEN_UP) {
collapseAngle = mLabelsPosition == LABELS_POSITION_LEFT ? OPENED_PLUS_ROTATION_LEFT : OPENED_PLUS_ROTATION_RIGHT;
expandAngle = mLabelsPosition == LABELS_POSITION_LEFT ? OPENED_PLUS_ROTATION_LEFT : OPENED_PLUS_ROTATION_RIGHT;
} else {
collapseAngle = mLabelsPosition == LABELS_POSITION_LEFT ? OPENED_PLUS_ROTATION_RIGHT : OPENED_PLUS_ROTATION_LEFT;
expandAngle = mLabelsPosition == LABELS_POSITION_LEFT ? OPENED_PLUS_ROTATION_RIGHT : OPENED_PLUS_ROTATION_LEFT;
}
ObjectAnimator collapseAnimator = ObjectAnimator.ofFloat(mImageToggle, "rotation", collapseAngle, CLOSED_PLUS_ROTATION);
ObjectAnimator expandAnimator = ObjectAnimator.ofFloat(mImageToggle, "rotation", CLOSED_PLUS_ROTATION, expandAngle);
mOpenAnimatorSet.play(expandAnimator);
mCloseAnimatorSet.play(collapseAnimator);
mOpenAnimatorSet.setInterpolator(mOpenInterpolator);
mCloseAnimatorSet.setInterpolator(mCloseInterpolator);
mOpenAnimatorSet.setDuration(ANIMATION_DURATION);
mCloseAnimatorSet.setDuration(ANIMATION_DURATION);
}
19
Source : FloatingActionMenu.java
with Apache License 2.0
from sougata-chatterjee
with Apache License 2.0
from sougata-chatterjee
public void setIconAnimationCloseInterpolator(Interpolator closeInterpolator) {
mCloseAnimatorSet.setInterpolator(closeInterpolator);
}
19
Source : FloatingActionMenu.java
with Apache License 2.0
from sougata-chatterjee
with Apache License 2.0
from sougata-chatterjee
public void setIconAnimationOpenInterpolator(Interpolator openInterpolator) {
mOpenAnimatorSet.setInterpolator(openInterpolator);
}
19
Source : BoomAnimator.java
with Apache License 2.0
from SmartisanTech
with Apache License 2.0
from SmartisanTech
private static Animator makeScaleAnimator(final View view, float from, float to, long duration) {
AnimatorSet animatorSet = new AnimatorSet();
ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, View.SCALE_X, from, to);
ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, View.SCALE_Y, from, to);
animatorSet.setInterpolator(mIterpolator);
animatorSet.setDuration(duration);
animatorSet.play(scaleX).with(scaleY);
return animatorSet;
}
19
Source : WormAnimation.java
with Apache License 2.0
from smarteist
with Apache License 2.0
from smarteist
@NonNull
@Override
public AnimatorSet createAnimator() {
AnimatorSet animator = new AnimatorSet();
animator.setInterpolator(new AccelerateDecelerateInterpolator());
return animator;
}
19
Source : TapBarMenu.java
with GNU General Public License v3.0
from rosenpin
with GNU General Public License v3.0
from rosenpin
private void setupAnimators() {
for (int i = 0; i < 5; i++) {
animator[i] = new ValueAnimator();
}
animator[LEFT].addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
button[LEFT] = (float) valueAnimator.getAnimatedValue();
}
});
animator[RIGHT].addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
button[RIGHT] = (float) valueAnimator.getAnimatedValue();
}
});
animator[TOP].addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
button[TOP] = (float) valueAnimator.getAnimatedValue();
}
});
animator[BOTTOM].addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
button[BOTTOM] = (float) valueAnimator.getAnimatedValue();
}
});
animator[RADIUS].addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
button[RADIUS] = (float) valueAnimator.getAnimatedValue();
invalidate();
}
});
animationDuration = getResources().getInteger(R.integer.animationDuration);
animatorSet.setDuration(animationDuration);
animatorSet.setInterpolator(DECELERATE_INTERPOLATOR);
animatorSet.playTogether(animator);
}
19
Source : PointAnimView.java
with Apache License 2.0
from REBOOTERS
with Apache License 2.0
from REBOOTERS
private void initAnimation() {
Point startP = new Point(RADIUS, RADIUS);
Point endP = new Point(getWidth() - RADIUS, getHeight() - RADIUS);
final ValueAnimator valueAnimator = ValueAnimator.ofObject(new PointSinEvaluator(), startP, endP);
valueAnimator.setRepeatCount(-1);
valueAnimator.setRepeatMode(ValueAnimator.REVERSE);
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
currentPoint = (Point) animation.getAnimatedValue();
postInvalidate();
}
});
//
Resources mResources = getResources();
int green = mResources.getColor(R.color.cpb_green_dark);
int primary = mResources.getColor(R.color.colorPrimary);
int red = mResources.getColor(R.color.cpb_red_dark);
int orange = mResources.getColor(R.color.orange);
int accent = mResources.getColor(R.color.colorAccent);
ObjectAnimator animColor = ObjectAnimator.ofObject(this, "color", new ArgbEvaluator(), green, primary, red, orange, accent);
animColor.setRepeatCount(-1);
animColor.setRepeatMode(ValueAnimator.REVERSE);
ValueAnimator animScale = ValueAnimator.ofFloat(20f, 80f, 60f, 10f, 35f, 55f, 10f);
animScale.setRepeatCount(-1);
animScale.setRepeatMode(ValueAnimator.REVERSE);
animScale.setDuration(5000);
animScale.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
radius = (float) animation.getAnimatedValue();
}
});
animSet = new AnimatorSet();
animSet.play(valueAnimator).with(animColor).with(animScale);
animSet.setDuration(5000);
animSet.setInterpolator(interpolatorType);
}
19
Source : PropertyAnimationActivity.java
with Apache License 2.0
from RealMoMo
with Apache License 2.0
from RealMoMo
/**
* AnimatorSet usage
*
* @return
*/
public AnimatorSet getAnimatorSet() {
AnimatorSet animatorSet = new AnimatorSet();
// play together
{
// animatorSet.play(getObjectAnimator(true))
// .with(getObjectAnimator(false))
// .with(getValueAnimator());
}
// play sequentially
{
// animatorSet.play(getObjectAnimator(true))
// .after(getObjectAnimator(false))
// .before(getValueAnimator());
}
animatorSet.playTogether(getObjectAnimatorByPropertyValuesHolder(), getValueAnimator());
animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
return animatorSet;
}
19
Source : EasyPhotosActivity.java
with MIT License
from qunarcorp
with MIT License
from qunarcorp
private void newShowAnim() {
ObjectAnimator translationShow = ObjectAnimator.ofFloat(rvAlbumItems, "translationY", mBottomBar.getTop(), 0);
ObjectAnimator alphaShow = ObjectAnimator.ofFloat(rootViewAlbumItems, "alpha", 0.0f, 1.0f);
translationShow.setDuration(300);
setShow = new AnimatorSet();
setShow.setInterpolator(new AccelerateDecelerateInterpolator());
setShow.play(translationShow).with(alphaShow);
}
19
Source : ShutterButton.java
with GNU General Public License v3.0
from NekoX-Dev
with GNU General Public License v3.0
from NekoX-Dev
private void setHighlighted(boolean value) {
AnimatorSet animatorSet = new AnimatorSet();
if (value) {
animatorSet.playTogether(ObjectAnimator.ofFloat(this, View.SCALE_X, 1.06f), ObjectAnimator.ofFloat(this, View.SCALE_Y, 1.06f));
} else {
animatorSet.playTogether(ObjectAnimator.ofFloat(this, View.SCALE_X, 1.0f), ObjectAnimator.ofFloat(this, View.SCALE_Y, 1.0f));
animatorSet.setStartDelay(40);
}
animatorSet.setDuration(120);
animatorSet.setInterpolator(interpolator);
animatorSet.start();
}
19
Source : mainpage_ui_test.java
with MIT License
from murtaza98
with MIT License
from murtaza98
private void foundDevice(View foundDevice) {
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.setDuration(400);
animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
ArrayList<Animator> animatorList = new ArrayList<Animator>();
ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(foundDevice, "ScaleX", 0f, 1.2f, 1f);
animatorList.add(scaleXAnimator);
ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(foundDevice, "ScaleY", 0f, 1.2f, 1f);
animatorList.add(scaleYAnimator);
animatorSet.playTogether(animatorList);
foundDevice.setVisibility(View.VISIBLE);
animatorSet.start();
}
19
Source : DetailActivity.java
with Apache License 2.0
from MrDeclanCoder
with Apache License 2.0
from MrDeclanCoder
private void initAnimation() {
scaleXAnim = ObjectAnimator.ofFloat(floatingactionbutton_details, "scaleX", 1.3f, 0.8f, 1.0f);
scaleYAnim = ObjectAnimator.ofFloat(floatingactionbutton_details, "scaleY", 1.3f, 0.8f, 1.0f);
animatorSet = new AnimatorSet();
animatorSet.play(scaleXAnim).with(scaleYAnim);
animatorSet.setDuration(1000);
animatorSet.setInterpolator(new DecelerateInterpolator());
}
19
Source : PreciseLocationActivity.java
with Apache License 2.0
from littleRich
with Apache License 2.0
from littleRich
/**
* 使组件变回原有形状
* @param view
*/
private void repaintView(final View view) {
AnimatorSet set = new AnimatorSet();
ValueAnimator animator = ValueAnimator.ofFloat(width, 0);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float value = (Float) animation.getAnimatedValue();
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) mBeginLocation.getLayoutParams();
params.leftMargin = (int) value;
params.rightMargin = (int) value;
view.setLayoutParams(params);
}
});
ObjectAnimator animator2 = ObjectAnimator.ofFloat(view, "scaleX", 0.5f, 1f);
set.setDuration(1000);
set.setInterpolator(new AccelerateDecelerateInterpolator());
set.playTogether(animator, animator2);
set.start();
}
19
Source : EqualizerView.java
with GNU General Public License v3.0
from KaustubhPatange
with GNU General Public License v3.0
from KaustubhPatange
public void animateBars() {
isAnimating = true;
if (isInBatterySaveMode()) {
if (mRunInBatterySafeMode) {
new Thread(mAnimationThread).start();
}
} else {
if (mPlayingSet == null) {
for (int i = 0; i < mBars.size(); i++) {
Random rand = new Random();
float[] values = new float[DEFAULT_ANIMATION_COUNT];
for (int j = 0; j < DEFAULT_ANIMATION_COUNT; j++) {
values[j] = rand.nextFloat();
}
ObjectAnimator scaleYbar = ObjectAnimator.ofFloat(mBars.get(i), "scaleY", values);
scaleYbar.setRepeatCount(ValueAnimator.INFINITE);
scaleYbar.setRepeatMode(ObjectAnimator.REVERSE);
mAnimators.add(scaleYbar);
}
mPlayingSet = new AnimatorSet();
mPlayingSet.playTogether(mAnimators);
mPlayingSet.setDuration(mAnimationDuration);
mPlayingSet.setInterpolator(new LinearInterpolator());
mPlayingSet.start();
} else if (Build.VERSION.SDK_INT < 19) {
if (!mPlayingSet.isStarted()) {
mPlayingSet.start();
}
} else {
if (mPlayingSet.isPaused()) {
mPlayingSet.resume();
}
}
}
}
19
Source : MainActivity.java
with MIT License
from JZ-Darkal
with MIT License
from JZ-Darkal
// @Override
// protected void onSaveInstanceState(Bundle outState) {
// int tab;
// if (mBackHandedFragment instanceof PreviewFragment) {
// tab = 3;
// } else if (mBackHandedFragment instanceof NetworkFragment) {
// tab = 2;
// } else {
// tab = 1;
// }
// outState.putInt("tab", tab);
// super.onSaveInstanceState(outState);
// }
public void initFloatingActionMenu() {
fam.setClosedOnTouchOutside(true);
AnimatorSet set = new AnimatorSet();
ObjectAnimator scaleOutX = ObjectAnimator.ofFloat(fam.getMenuIconView(), "scaleX", 1.0f, 0.2f);
ObjectAnimator scaleOutY = ObjectAnimator.ofFloat(fam.getMenuIconView(), "scaleY", 1.0f, 0.2f);
ObjectAnimator scaleInX = ObjectAnimator.ofFloat(fam.getMenuIconView(), "scaleX", 0.2f, 1.0f);
ObjectAnimator scaleInY = ObjectAnimator.ofFloat(fam.getMenuIconView(), "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) {
fam.getMenuIconView().setImageResource(fam.isOpened() ? R.drawable.ic_file_upload_white_24dp : R.drawable.ic_close_white_24dp);
if (mBackHandedFragment instanceof PreviewFragment) {
if (fam.isOpened()) {
clearFab.show(true);
} else {
clearFab.hide(true);
}
}
}
});
set.play(scaleOutX).with(scaleOutY);
set.play(scaleInX).with(scaleInY).after(scaleOutX);
set.setInterpolator(new OvershootInterpolator(2));
fam.setIconToggleAnimatorSet(set);
shareFab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showFilter(MainActivity.this, TYPE_SHARE);
fam.close(true);
}
});
uploadFab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showFilter(MainActivity.this, TYPE_UPLOAD);
fam.close(true);
}
});
previewFab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
switchContent(PreviewFragment.getInstance());
fam.close(true);
}
});
clearFab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setreplacedle("请确认是否清除所有请求?");
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
((SysApplication) getApplication()).proxy.getHar().getLog().clearAllEntries();
PreviewFragment.getInstance().notifyHarChange();
}
});
builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
});
builder.create().show();
}
});
}
19
Source : InstagramViewPager.java
with Apache License 2.0
from JessYanCoding
with Apache License 2.0
from JessYanCoding
private void startChildAnimation(float destination, long duration) {
if (mAnimatorSet != null && mAnimatorSet.isRunning()) {
mAnimatorSet.cancel();
}
mAnimatorSet = new AnimatorSet();
mAnimatorSet.playTogether(ObjectAnimator.ofFloat(this, "scrollHorizontalPosition", scrollHorizontalPosition, destination));
mAnimatorSet.setInterpolator(Interpolator);
mAnimatorSet.setDuration(duration);
mAnimatorSet.start();
}
19
Source : MovingViewAnimator.java
with Apache License 2.0
from JaynmBo
with Apache License 2.0
from JaynmBo
public void setInterpolator(Interpolator interpolator) {
mInterpolator = interpolator;
mAnimatorSet.setInterpolator(interpolator);
}
19
Source : BezierPraiseAnimator.java
with Apache License 2.0
from HpWens
with Apache License 2.0
from HpWens
/**
* 获取到点赞小图标动画
*
* @param target
* @return
*/
private Animator getPraiseAnimator(View target) {
// 获取贝塞尔曲线动画
ValueAnimator bezierPraiseAnimator = getBezierPraiseAnimator(target);
// 组合动画(旋转动画+贝塞尔曲线动画)旋转角度(200~720)
int rotationAngle = mRandom.nextInt(520) + 200;
ObjectAnimator rotationAnimator = ObjectAnimator.ofFloat(target, "rotation", 0, rotationAngle % 2 == 0 ? rotationAngle : -rotationAngle);
rotationAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
rotationAnimator.setTarget(target);
// 组合动画
AnimatorSet composeAnimator = new AnimatorSet();
composeAnimator.play(bezierPraiseAnimator).with(rotationAnimator);
composeAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
composeAnimator.setDuration(mAnimatorDuration);
composeAnimator.setTarget(target);
return composeAnimator;
}
19
Source : LoginActivity.java
with Apache License 2.0
from FreddyChen
with Apache License 2.0
from FreddyChen
private void startAnimator(boolean isShow) {
if (isAnimatorDisplayed == isShow) {
return;
}
isAnimatorDisplayed = isShow;
float logoFromScaleXValue = isShow ? 1.0f : 0.65f;
float logoToScaleYValue = isShow ? 0.65f : 1.0f;
float logoFromTranslationYValue = isShow ? 0.0f : -DensityUtil.dp2px(64);
float logoToTranslationYValue = isShow ? -DensityUtil.dp2px(64) : 0.0f;
float bodyLayoutFromTranslationYValue = isShow ? 0.0f : -DensityUtil.dp2px(118);
float bodyLayoutToTranslationYValue = isShow ? -DensityUtil.dp2px(118) : 0.0f;
ObjectAnimator logoScaleXAnimator = ObjectAnimator.ofFloat(mLogoImageView, CConfig.ANIMATOR_SCALE_X, logoFromScaleXValue, logoToScaleYValue);
ObjectAnimator logoScaleYAnimator = ObjectAnimator.ofFloat(mLogoImageView, CConfig.ANIMATOR_SCALE_Y, logoFromScaleXValue, logoToScaleYValue);
ObjectAnimator logoTranslationYAnimator = ObjectAnimator.ofFloat(mLogoImageView, CConfig.ANIMATOR_TRANSLATION_Y, logoFromTranslationYValue, logoToTranslationYValue);
ObjectAnimator bodyLayoutTranslationYAnimator = ObjectAnimator.ofFloat(mBodyLayout, CConfig.ANIMATOR_TRANSLATION_Y, bodyLayoutFromTranslationYValue, bodyLayoutToTranslationYValue);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.play(logoScaleXAnimator).with(logoScaleYAnimator).with(logoTranslationYAnimator).with(bodyLayoutTranslationYAnimator);
animatorSet.setInterpolator(new DecelerateInterpolator());
animatorSet.setDuration(250);
animatorSet.start();
}
19
Source : TranslationReadActivity.java
with GNU General Public License v3.0
from fekracomputers
with GNU General Public License v3.0
from fekracomputers
/**
* Function to hide tool bar "animation"
*/
public void hideToolbar() {
ObjectAnimator animY = ObjectAnimator.ofFloat(header, "y", -(header.getHeight()));
AnimatorSet animSetXY = new AnimatorSet();
animSetXY.setInterpolator(new LinearInterpolator());
animSetXY.play(animY);
animSetXY.start();
}
19
Source : TranslationReadActivity.java
with GNU General Public License v3.0
from fekracomputers
with GNU General Public License v3.0
from fekracomputers
/**
* Function to show tool bar "animation"
*/
public void showToolbar() {
ObjectAnimator animY = ObjectAnimator.ofFloat(header, "y", 0);
AnimatorSet animSetXY = new AnimatorSet();
animSetXY.setInterpolator(new LinearInterpolator());
animSetXY.play(animY);
animSetXY.start();
}
19
Source : CoolMenu.java
with Apache License 2.0
from crazysunj
with Apache License 2.0
from crazysunj
// 显示动画,可以自己调
public void show() {
int childCount = getChildCount();
if (childCount > 1) {
// 复位
mAngle = 0;
float x = 0.5f * mEdge;
float y = 0.5f * mEdge;
Animator[] anim = new Animator[childCount];
for (int i = 0; i < childCount; i++) {
View child = getChildAt(i);
float pivotX = x - child.getLeft();
float pivotY = y - child.getTop();
child.setPivotX(pivotX);
child.setPivotY(pivotY);
float childX = 0.5f * child.getLeft() + child.getRight() * 0.5f;
float childY = 0.5f * child.getTop() + 0.5f * child.getBottom();
PropertyValuesHolder ca = PropertyValuesHolder.ofFloat("alpha", 0.5f, 1.0f);
PropertyValuesHolder csx = PropertyValuesHolder.ofFloat("scaleX", 0, 1.0f);
PropertyValuesHolder csy = PropertyValuesHolder.ofFloat("scaleY", 0, 1.0f);
if (i == 0) {
anim[i] = ObjectAnimator.ofPropertyValuesHolder(child, ca, csx, csy);
} else {
PropertyValuesHolder ctx = PropertyValuesHolder.ofFloat("translationX", -x + childX, 0);
PropertyValuesHolder cty = PropertyValuesHolder.ofFloat("translationY", -y + childY, 0);
PropertyValuesHolder cr = PropertyValuesHolder.ofFloat("rotation", 0, 360f);
anim[i] = ObjectAnimator.ofPropertyValuesHolder(child, ctx, cty, ca, csx, csy, cr);
}
}
AnimatorSet set = new AnimatorSet();
set.setDuration(ANIM_SHOW_DURATION);
set.setInterpolator(new LinearInterpolator());
set.playTogether(anim);
set.start();
}
}
19
Source : CoolMenu.java
with Apache License 2.0
from crazysunj
with Apache License 2.0
from crazysunj
// 关闭时动画
public void dismiss() {
int childCount = getChildCount();
if (childCount > 1) {
float x = 0.5f * mEdge;
float y = 0.5f * mEdge;
Animator[] before = new Animator[childCount];
Animator[] after = new Animator[childCount - 1];
for (int i = 0; i < childCount; i++) {
View child = getChildAt(i);
float pivotX = x - child.getLeft();
float pivotY = y - child.getTop();
float childX = 0.5f * child.getLeft() + child.getRight() * 0.5f;
float childY = 0.5f * child.getTop() + 0.5f * child.getBottom();
child.setPivotX(pivotX);
child.setPivotY(pivotY);
PropertyValuesHolder ca = PropertyValuesHolder.ofFloat("alpha", 1.0f, 0);
PropertyValuesHolder csx = PropertyValuesHolder.ofFloat("scaleX", 1.0f, 0);
PropertyValuesHolder csy = PropertyValuesHolder.ofFloat("scaleY", 1.0f, 0);
if (i == 0) {
before[i] = ObjectAnimator.ofPropertyValuesHolder(child, ca, csx, csy);
} else {
PropertyValuesHolder ctx = PropertyValuesHolder.ofFloat("translationX", 0, x - childX);
PropertyValuesHolder cty = PropertyValuesHolder.ofFloat("translationY", 0, y - childY);
PropertyValuesHolder cr = PropertyValuesHolder.ofFloat("rotation", 0, 360f);
before[i] = ObjectAnimator.ofPropertyValuesHolder(child, cr, ctx, cty);
PropertyValuesHolder cx = PropertyValuesHolder.ofFloat("translationX", x - childX, (childX - x) * 10);
PropertyValuesHolder cy = PropertyValuesHolder.ofFloat("translationY", y - childY, (childY - y) * 10);
after[i - 1] = ObjectAnimator.ofPropertyValuesHolder(child, cx, cy);
}
}
AnimatorSet set = new AnimatorSet();
AnimatorSet first = new AnimatorSet();
AnimatorSet last = new AnimatorSet();
first.playTogether(before);
last.playTogether(after);
set.setDuration(ANIM_DISMISS_DURATION);
set.setInterpolator(new DecelerateInterpolator());
set.play(first).before(last);
set.start();
}
}
19
Source : RippleLayout.java
with Apache License 2.0
from coderJohnZhang
with Apache License 2.0
from coderJohnZhang
private void initAnimSet() {
mAnimatorSet.setDuration(mAnimDuration);
mAnimatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
}
19
Source : CameraActivity.java
with GNU General Public License v2.0
from chengzichen
with GNU General Public License v2.0
from chengzichen
private boolean processTouchEvent(MotionEvent event) {
if (!pressed && event.getActionMasked() == MotionEvent.ACTION_DOWN || event.getActionMasked() == MotionEvent.ACTION_POINTER_DOWN) {
if (!takingPhoto) {
pressed = true;
maybeStartDraging = true;
lastY = event.getY();
}
} else if (pressed) {
if (event.getActionMasked() == MotionEvent.ACTION_MOVE) {
} else if (event.getActionMasked() == MotionEvent.ACTION_CANCEL || event.getActionMasked() == MotionEvent.ACTION_UP || event.getActionMasked() == MotionEvent.ACTION_POINTER_UP) {
pressed = false;
if (dragging) {
dragging = false;
if (cameraView != null) {
if (Math.abs(cameraView.getTranslationY()) > cameraView.getMeasuredHeight() / 6.0f) {
closeCamera(true);
} else {
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(ObjectAnimator.ofFloat(cameraView, "translationY", 0.0f), ObjectAnimator.ofFloat(cameraPanel, "alpha", 1.0f), ObjectAnimator.ofFloat(flashModeButton[0], "alpha", 1.0f), ObjectAnimator.ofFloat(flashModeButton[1], "alpha", 1.0f));
animatorSet.setDuration(250);
animatorSet.setInterpolator(interpolator);
animatorSet.start();
cameraPanel.setTag(null);
}
}
} else {
cameraView.getLocationOnScreen(viewPosition);
float viewX = event.getRawX() - viewPosition[0];
float viewY = event.getRawY() - viewPosition[1];
cameraView.focusToPoint((int) viewX, (int) viewY);
}
}
}
return true;
}
19
Source : MultiFloatingActionButton.java
with Apache License 2.0
from chengkun123
with Apache License 2.0
from chengkun123
private void bounceToShow() {
for (int i = 2; i < getChildCount(); i++) {
View view = getChildAt(i);
view.setVisibility(VISIBLE);
ObjectAnimator trans = ObjectAnimator.ofFloat(view, "translationY", 50f, 0);
ObjectAnimator show = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f);
AnimatorSet set = new AnimatorSet();
set.play(trans).with(show);
set.setDuration(mAnimationDuration);
set.setInterpolator(new BounceInterpolator());
set.start();
}
}
19
Source : UDAnimatorSet.java
with MIT License
from alibaba
with MIT License
from alibaba
/**
* 加速器
* AccelerateDecelerateInterpolator,
* AccelerateInterpolator,
* AnticipateInterpolator,
* AnticipateOvershootInterpolator,
* BaseInterpolator,
* BounceInterpolator,
* CycleInterpolator,
* DecelerateInterpolator,
* FastOutLinearInInterpolator,
* FastOutSlowInInterpolator,
* LinearInterpolator,
* LinearOutSlowInInterpolator,
* OvershootInterpolator,
* PathInterpolator
*
* @param interpolator
* @return
*/
public UDAnimatorSet setInterpolator(final Interpolator interpolator) {
final AnimatorSet animator = getAnimatorSet();
if (animator != null && interpolator != null) {
animator.setInterpolator(interpolator);
}
return this;
}
18
Source : SimpleAnimatorChain.java
with MIT License
from zj565061763
with MIT License
from zj565061763
@Override
public AnimatorChain setInterpolator(TimeInterpolator interpolator) {
mAnimatorSet.setInterpolator(interpolator);
mTimeInterpolator = interpolator;
return this;
}
18
Source : ElectricFanLoadingRenderer.java
with Apache License 2.0
from Yuphee
with Apache License 2.0
from Yuphee
private Animator getAnimator(LeafHolder target, RectF leafFlyRect, float progress) {
ValueAnimator bezierValueAnimator = getBezierValueAnimator(target, leafFlyRect, progress);
AnimatorSet finalSet = new AnimatorSet();
finalSet.playSequentially(bezierValueAnimator);
finalSet.setInterpolator(INTERPOLATORS[mRandom.nextInt(INTERPOLATORS.length)]);
finalSet.setTarget(target);
return finalSet;
}
18
Source : ModeTransitionView.java
with Apache License 2.0
from Yuloran
with Apache License 2.0
from Yuloran
/**
* Starts the peep hole animation where the circle is centered at position (x, y).
*/
private void startPeepHoleAnimation(float x, float y) {
if (mPeepHoleAnimator != null && mPeepHoleAnimator.isRunning()) {
return;
}
mAnimationType = PEEP_HOLE_ANIMATION;
mPeepHoleCenterX = (int) x;
mPeepHoleCenterY = (int) y;
int horizontalDistanceToFarEdge = Math.max(mPeepHoleCenterX, mWidth - mPeepHoleCenterX);
int verticalDistanceToFarEdge = Math.max(mPeepHoleCenterY, mHeight - mPeepHoleCenterY);
int endRadius = (int) (Math.sqrt(horizontalDistanceToFarEdge * horizontalDistanceToFarEdge + verticalDistanceToFarEdge * verticalDistanceToFarEdge));
final ValueAnimator radiusAnimator = ValueAnimator.ofFloat(0, endRadius);
radiusAnimator.setDuration(PEEP_HOLE_ANIMATION_DURATION_MS);
final ValueAnimator iconScaleAnimator = ValueAnimator.ofFloat(1f, 0.5f);
iconScaleAnimator.setDuration(ICON_FADE_OUT_DURATION_MS);
final ValueAnimator iconAlphaAnimator = ValueAnimator.ofInt(ALPHA_HALF_TRANSPARENT, ALPHA_FULLY_TRANSPARENT);
iconAlphaAnimator.setDuration(ICON_FADE_OUT_DURATION_MS);
mPeepHoleAnimator = new AnimatorSet();
mPeepHoleAnimator.playTogether(radiusAnimator, iconAlphaAnimator, iconScaleAnimator);
mPeepHoleAnimator.setInterpolator(Gusterpolator.INSTANCE);
iconAlphaAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
// Modify mask by enlarging the hole
mRadius = (Float) radiusAnimator.getAnimatedValue();
mIconDrawable.setAlpha((Integer) iconAlphaAnimator.getAnimatedValue());
float scale = (Float) iconScaleAnimator.getAnimatedValue();
int size = (int) (scale * (float) mIconSize);
mIconDrawable.setBounds(mPeepHoleCenterX - size / 2, mPeepHoleCenterY - size / 2, mPeepHoleCenterX + size / 2, mPeepHoleCenterY + size / 2);
invalidate();
}
});
mPeepHoleAnimator.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
// Sets a HW layer on the view for the animation.
setLayerType(LAYER_TYPE_HARDWARE, null);
}
@Override
public void onAnimationEnd(Animator animation) {
// Sets the layer type back to NONE as a workaround for b/12594617.
setLayerType(LAYER_TYPE_NONE, null);
mPeepHoleAnimator = null;
mRadius = 0;
mIconDrawable.setAlpha(ALPHA_FULLY_OPAQUE);
mIconDrawable.setBounds(mIconRect);
setVisibility(GONE);
mAnimationType = IDLE;
if (mAnimationFinishedListener != null) {
mAnimationFinishedListener.onAnimationFinished(true);
mAnimationFinishedListener = null;
}
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
mPeepHoleAnimator.start();
}
18
Source : HomeGridItemAnimator.java
with Apache License 2.0
from yongjhih
with Apache License 2.0
from yongjhih
private void animateStoryCommentReturn(final FeedAdapter.DesignerNewsStoryHolder holder) {
endAnimation(holder);
AnimatorSet commentsReturnAnim = new AnimatorSet();
commentsReturnAnim.playTogether(ObjectAnimator.ofFloat(holder.pocket, View.ALPHA, 0f, 1f), ObjectAnimator.ofFloat(holder.comments, View.ALPHA, 0f, 1f));
commentsReturnAnim.setDuration(120L);
commentsReturnAnim.setInterpolator(AnimUtils.getLinearOutSlowInInterpolator(holder.itemView.getContext()));
commentsReturnAnim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
dispatchChangeStarting(holder, false);
}
@Override
public void onAnimationEnd(Animator animation) {
runningStoryCommentsReturn = null;
dispatchChangeFinished(holder, false);
}
@Override
public void onAnimationCancel(Animator animation) {
holder.pocket.setAlpha(1f);
holder.comments.setAlpha(1f);
runningStoryCommentsReturn = null;
dispatchChangeFinished(holder, false);
}
});
runningStoryCommentsReturn = Pair.create(holder, commentsReturnAnim);
commentsReturnAnim.start();
}
18
Source : BaseViewAnimator.java
with Apache License 2.0
from yibulaxi
with Apache License 2.0
from yibulaxi
public BaseViewAnimator setInterpolator(Interpolator interpolator) {
mAnimatorSet.setInterpolator(interpolator);
return this;
}
18
Source : EnterScreenAnimations.java
with Apache License 2.0
from yangchong211
with Apache License 2.0
from yangchong211
/**
* This method combines several animations when screen is opened.
* 1. Animation of ImageView position and image matrix.
* 2. Animation of main container elements - they are fading in after image is animated to position
*/
public void playEnteringAnimation(int left, int top, int width, int height) {
mToLeft = left;
mToTop = top;
mToWidth = width;
mToHeight = height;
AnimatorSet imageAnimatorSet = createEnteringImageAnimation();
Animator mainContainerFadeAnimator = createEnteringFadeAnimator();
mEnteringAnimation = new AnimatorSet();
mEnteringAnimation.setDuration(IMAGE_TRANSLATION_DURATION);
mEnteringAnimation.setInterpolator(new AccelerateInterpolator());
mEnteringAnimation.addListener(new SimpleAnimationListener() {
@Override
public void onAnimationCancel(Animator animation) {
Log.v(TAG, "onAnimationCancel, mEnteringAnimation " + mEnteringAnimation);
mEnteringAnimation = null;
}
@Override
public void onAnimationEnd(Animator animation) {
Log.v(TAG, "onAnimationEnd, mEnteringAnimation " + mEnteringAnimation);
if (mEnteringAnimation != null) {
mEnteringAnimation = null;
mImageTo.setVisibility(View.VISIBLE);
mAnimatedImage.setVisibility(View.INVISIBLE);
}
}
});
mEnteringAnimation.playTogether(imageAnimatorSet, mainContainerFadeAnimator);
mEnteringAnimation.start();
}
18
Source : EasyIndicator.java
with Apache License 2.0
from xuexiangjys
with Apache License 2.0
from xuexiangjys
private AnimatorSet buildIndicatorAnimatorTowards(TextView tv) {
float x = tab_content.getX();
ObjectAnimator xAnimator = ObjectAnimator.ofFloat(mIndicator, "X", mIndicator.getX(), tv.getX() + x);
final ViewGroup.LayoutParams params = mIndicator.getLayoutParams();
ValueAnimator widthAnimator = ValueAnimator.ofInt(params.width, tv.getMeasuredWidth());
widthAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
params.width = (Integer) animation.getAnimatedValue();
mIndicator.setLayoutParams(params);
}
});
AnimatorSet set = new AnimatorSet();
set.setInterpolator(new FastOutSlowInInterpolator());
set.playTogether(xAnimator, widthAnimator);
return set;
}
18
Source : CheckBox.java
with Apache License 2.0
from wuyinlei
with Apache License 2.0
from wuyinlei
private void animationStart() {
if (isHook) {
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(valueAnimator1, valueAnimator2, valueAnimator3, valueAnimator4, valueAnimatorBorder, valueAnimator);
animatorSet.setInterpolator(new DecelerateInterpolator());
valueAnimatorBorder.setInterpolator(new AccelerateInterpolator());
animatorSet.setDuration(Duration);
animatorSet.start();
} else {
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(cValueAnimator, cValueAnimator1, valueAnimatorBorder, valueAnimator);
animatorSet.setInterpolator(new DecelerateInterpolator());
valueAnimatorBorder.setInterpolator(new AccelerateInterpolator());
animatorSet.setDuration(Duration);
animatorSet.start();
}
}
18
Source : AbsFocusBorder.java
with Apache License 2.0
from wangxiaoxuan217
with Apache License 2.0
from wangxiaoxuan217
protected void createBorderAnimation(View focusView, Options options) {
final float paddingWidth = mPaddingRectF.left + mPaddingRectF.right + mPaddingOfsetRectF.left + mPaddingOfsetRectF.right;
final float paddingHeight = mPaddingRectF.top + mPaddingRectF.bottom + mPaddingOfsetRectF.top + mPaddingOfsetRectF.bottom;
final int newWidth = (int) (focusView.getMeasuredWidth() * options.scaleX + paddingWidth);
final int newHeight = (int) (focusView.getMeasuredHeight() * options.scaleY + paddingHeight);
final Rect fromRect = findLocationWithView(this);
final Rect toRect = findLocationWithView(focusView);
final int x = toRect.left - fromRect.left;
final int y = toRect.top - fromRect.top;
final float newX = x - Math.abs(focusView.getMeasuredWidth() - newWidth) / 2f;
final float newY = y - Math.abs(focusView.getMeasuredHeight() - newHeight) / 2f;
final List<Animator> together = new ArrayList<>();
final List<Animator> appendTogether = getTogetherAnimators(newX, newY, newWidth, newHeight, options);
together.add(getTranslationXAnimator(newX));
together.add(getTranslationYAnimator(newY));
together.add(getWidthAnimator(newWidth));
together.add(getHeightAnimator(newHeight));
if (null != appendTogether && !appendTogether.isEmpty()) {
together.addAll(appendTogether);
}
final List<Animator> sequentially = new ArrayList<>();
final List<Animator> appendSequentially = getSequentiallyAnimators(newX, newY, newWidth, newHeight, options);
if (mIsShimmerAnim) {
sequentially.add(getShimmerAnimator());
}
if (null != appendSequentially && !appendSequentially.isEmpty()) {
sequentially.addAll(appendSequentially);
}
mAnimatorSet = new AnimatorSet();
mAnimatorSet.setInterpolator(new DecelerateInterpolator(1));
mAnimatorSet.playTogether(together);
mAnimatorSet.playSequentially(sequentially);
}
18
Source : AnimatorAdapter.java
with Apache License 2.0
from triline3
with Apache License 2.0
from triline3
protected void initAnimatorSet() {
mSet = new AnimatorSet();
mSet.setInterpolator(new AccelerateDecelerateInterpolator());
mSet.setDuration(getDuration());
}
18
Source : DynamicGridView.java
with GNU Affero General Public License v3.0
from threema-ch
with GNU Affero General Public License v3.0
from threema-ch
private void animateReorder(final int oldPosition, final int newPosition) {
boolean isForward = newPosition > oldPosition;
List<Animator> resultList = new LinkedList<Animator>();
if (isForward) {
for (int pos = Math.min(oldPosition, newPosition); pos < Math.max(oldPosition, newPosition); pos++) {
View view = getViewForId(getId(pos));
if ((pos + 1) % getColumnCount() == 0) {
resultList.add(createTranslationAnimations(view, -view.getWidth() * (getColumnCount() - 1), 0, view.getHeight(), 0));
} else {
resultList.add(createTranslationAnimations(view, view.getWidth(), 0, 0, 0));
}
}
} else {
for (int pos = Math.max(oldPosition, newPosition); pos > Math.min(oldPosition, newPosition); pos--) {
View view = getViewForId(getId(pos));
if ((pos + getColumnCount()) % getColumnCount() == 0) {
resultList.add(createTranslationAnimations(view, view.getWidth() * (getColumnCount() - 1), 0, -view.getHeight(), 0));
} else {
resultList.add(createTranslationAnimations(view, -view.getWidth(), 0, 0, 0));
}
}
}
AnimatorSet resultSet = new AnimatorSet();
resultSet.playTogether(resultList);
resultSet.setDuration(MOVE_DURATION);
resultSet.setInterpolator(new AccelerateDecelerateInterpolator());
resultSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
mReorderAnimation = true;
updateEnableState();
}
@Override
public void onAnimationEnd(Animator animation) {
mReorderAnimation = false;
updateEnableState();
}
});
resultSet.start();
}
18
Source : PipRoundVideoView.java
with GNU General Public License v2.0
from TelePlusDev
with GNU General Public License v2.0
from TelePlusDev
public void showTemporary(boolean show) {
if (hideShowAnimation != null) {
hideShowAnimation.cancel();
}
hideShowAnimation = new AnimatorSet();
hideShowAnimation.playTogether(ObjectAnimator.ofFloat(windowView, "alpha", show ? 1.0f : 0.0f), ObjectAnimator.ofFloat(windowView, "scaleX", show ? 1.0f : 0.8f), ObjectAnimator.ofFloat(windowView, "scaleY", show ? 1.0f : 0.8f));
hideShowAnimation.setDuration(150);
if (decelerateInterpolator == null) {
decelerateInterpolator = new DecelerateInterpolator();
}
hideShowAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (animation.equals(hideShowAnimation)) {
hideShowAnimation = null;
}
}
});
hideShowAnimation.setInterpolator(decelerateInterpolator);
hideShowAnimation.start();
}
18
Source : PipRoundVideoView.java
with GNU General Public License v2.0
from TelePlusDev
with GNU General Public License v2.0
from TelePlusDev
private void animateToBoundsMaybe() {
int startX = getSideCoord(true, 0, 0, videoWidth);
int endX = getSideCoord(true, 1, 0, videoWidth);
int startY = getSideCoord(false, 0, 0, videoHeight);
int endY = getSideCoord(false, 1, 0, videoHeight);
ArrayList<Animator> animators = null;
SharedPreferences.Editor editor = preferences.edit();
int maxDiff = AndroidUtilities.dp(20);
boolean slideOut = false;
if (Math.abs(startX - windowLayoutParams.x) <= maxDiff || windowLayoutParams.x < 0 && windowLayoutParams.x > -videoWidth / 4) {
if (animators == null) {
animators = new ArrayList<>();
}
editor.putInt("sidex", 0);
if (windowView.getAlpha() != 1.0f) {
animators.add(ObjectAnimator.ofFloat(windowView, "alpha", 1.0f));
}
animators.add(ObjectAnimator.ofInt(this, "x", startX));
} else if (Math.abs(endX - windowLayoutParams.x) <= maxDiff || windowLayoutParams.x > AndroidUtilities.displaySize.x - videoWidth && windowLayoutParams.x < AndroidUtilities.displaySize.x - videoWidth / 4 * 3) {
if (animators == null) {
animators = new ArrayList<>();
}
editor.putInt("sidex", 1);
if (windowView.getAlpha() != 1.0f) {
animators.add(ObjectAnimator.ofFloat(windowView, "alpha", 1.0f));
}
animators.add(ObjectAnimator.ofInt(this, "x", endX));
} else if (windowView.getAlpha() != 1.0f) {
if (animators == null) {
animators = new ArrayList<>();
}
if (windowLayoutParams.x < 0) {
animators.add(ObjectAnimator.ofInt(this, "x", -videoWidth));
} else {
animators.add(ObjectAnimator.ofInt(this, "x", AndroidUtilities.displaySize.x));
}
slideOut = true;
} else {
editor.putFloat("px", (windowLayoutParams.x - startX) / (float) (endX - startX));
editor.putInt("sidex", 2);
}
if (!slideOut) {
if (Math.abs(startY - windowLayoutParams.y) <= maxDiff || windowLayoutParams.y <= ActionBar.getCurrentActionBarHeight()) {
if (animators == null) {
animators = new ArrayList<>();
}
editor.putInt("sidey", 0);
animators.add(ObjectAnimator.ofInt(this, "y", startY));
} else if (Math.abs(endY - windowLayoutParams.y) <= maxDiff) {
if (animators == null) {
animators = new ArrayList<>();
}
editor.putInt("sidey", 1);
animators.add(ObjectAnimator.ofInt(this, "y", endY));
} else {
editor.putFloat("py", (windowLayoutParams.y - startY) / (float) (endY - startY));
editor.putInt("sidey", 2);
}
editor.commit();
}
if (animators != null) {
if (decelerateInterpolator == null) {
decelerateInterpolator = new DecelerateInterpolator();
}
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.setInterpolator(decelerateInterpolator);
animatorSet.setDuration(150);
if (slideOut) {
animators.add(ObjectAnimator.ofFloat(windowView, "alpha", 0.0f));
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
close(false);
if (onCloseRunnable != null) {
onCloseRunnable.run();
}
}
});
}
animatorSet.playTogether(animators);
animatorSet.start();
}
}
18
Source : PipRoundVideoView.java
with GNU General Public License v2.0
from TelePlusDev
with GNU General Public License v2.0
from TelePlusDev
private void runShowHideAnimation(final boolean show) {
if (hideShowAnimation != null) {
hideShowAnimation.cancel();
}
hideShowAnimation = new AnimatorSet();
hideShowAnimation.playTogether(ObjectAnimator.ofFloat(windowView, "alpha", show ? 1.0f : 0.0f), ObjectAnimator.ofFloat(windowView, "scaleX", show ? 1.0f : 0.8f), ObjectAnimator.ofFloat(windowView, "scaleY", show ? 1.0f : 0.8f));
hideShowAnimation.setDuration(150);
if (decelerateInterpolator == null) {
decelerateInterpolator = new DecelerateInterpolator();
}
hideShowAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (animation.equals(hideShowAnimation)) {
if (!show) {
close(false);
}
hideShowAnimation = null;
}
}
@Override
public void onAnimationCancel(Animator animation) {
if (animation.equals(hideShowAnimation)) {
hideShowAnimation = null;
}
}
});
hideShowAnimation.setInterpolator(decelerateInterpolator);
hideShowAnimation.start();
}
18
Source : PhotoAttachPhotoCell.java
with GNU General Public License v2.0
from TelePlusDev
with GNU General Public License v2.0
from TelePlusDev
public void showCheck(boolean show) {
if (show && checkBox.getAlpha() == 1 || !show && checkBox.getAlpha() == 0) {
return;
}
if (animatorSet != null) {
animatorSet.cancel();
animatorSet = null;
}
animatorSet = new AnimatorSet();
animatorSet.setInterpolator(new DecelerateInterpolator());
animatorSet.setDuration(180);
animatorSet.playTogether(ObjectAnimator.ofFloat(videoInfoContainer, "alpha", show ? 1.0f : 0.0f), ObjectAnimator.ofFloat(checkBox, "alpha", show ? 1.0f : 0.0f));
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (animation.equals(animatorSet)) {
animatorSet = null;
}
}
});
animatorSet.start();
}
18
Source : DrawerLayoutContainer.java
with GNU General Public License v2.0
from TelePlusDev
with GNU General Public License v2.0
from TelePlusDev
public void closeDrawer(boolean fast) {
cancelCurrentAnimation();
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(ObjectAnimator.ofFloat(this, "drawerPosition", 0));
animatorSet.setInterpolator(new DecelerateInterpolator());
if (fast) {
animatorSet.setDuration(Math.max((int) (200.0f / drawerLayout.getMeasuredWidth() * drawerPosition), 50));
} else {
animatorSet.setDuration(300);
}
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animator) {
onDrawerAnimationEnd(false);
}
});
animatorSet.start();
}
18
Source : MusicalNoteLayout.java
with Apache License 2.0
from TaoPaox
with Apache License 2.0
from TaoPaox
// 出场动画
private AnimatorSet getEnterAnimator(final View target) {
ObjectAnimator alpha = ObjectAnimator.ofFloat(target, View.ALPHA, 0.1f, 1f);
ObjectAnimator scaleX = ObjectAnimator.ofFloat(target, View.SCALE_X, 0.0f, 1f);
ObjectAnimator scaleY = ObjectAnimator.ofFloat(target, View.SCALE_Y, 0.0f, 1f);
AnimatorSet enter = new AnimatorSet();
enter.setDuration(1000);
enter.setInterpolator(new AccelerateInterpolator());
enter.playTogether(alpha, scaleX, scaleY);
AnimatorSet before = new AnimatorSet();
// 同时在正负25f的角度上做随机旋转
ObjectAnimator rotate = ObjectAnimator.ofFloat(target, View.ROTATION, 0.0f, mRandom.nextInt(50) - 25.5f);
rotate.setDuration(2000);
before.playSequentially(enter, rotate);
return before;
}
See More Examples