use of android.view.animation.Interpolator in project floatingsearchview by arimorty.
the class MenuView method showIfRoomItems.
/**
* Shows all the menu items that were hidden by hideIfRoomItems(boolean withAnim)
*
* @param withAnim
*/
public void showIfRoomItems(boolean withAnim) {
if (mMenu == -1) {
return;
}
cancelChildAnimListAndClear();
if (mMenuItems.isEmpty()) {
return;
}
anims = new ArrayList<>();
for (int i = 0; i < getChildCount(); i++) {
final View currentView = getChildAt(i);
// reset all the action item views
if (i < mActionItems.size()) {
ImageView action = (ImageView) currentView;
final MenuItem actionItem = mActionItems.get(i);
action.setImageDrawable(actionItem.getIcon());
Util.setIconColor(action, mActionIconColor);
action.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mMenuCallback != null) {
mMenuCallback.onMenuItemSelected(mMenuBuilder, actionItem);
}
}
});
}
Interpolator interpolator = new DecelerateInterpolator();
if (i > (mActionShowAlwaysItems.size() - 1)) {
interpolator = new LinearInterpolator();
}
currentView.setClickable(true);
// simply animate all properties of all action item views back to their default/visible state
anims.add(ViewPropertyObjectAnimator.animate(currentView).addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
currentView.setTranslationX(0);
}
}).setInterpolator(interpolator).translationX(0).get());
anims.add(ViewPropertyObjectAnimator.animate(currentView).addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
currentView.setScaleX(1.0f);
}
}).setInterpolator(interpolator).scaleX(1.0f).get());
anims.add(ViewPropertyObjectAnimator.animate(currentView).addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
currentView.setScaleY(1.0f);
}
}).setInterpolator(interpolator).scaleY(1.0f).get());
anims.add(ViewPropertyObjectAnimator.animate(currentView).addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
currentView.setAlpha(1.0f);
}
}).setInterpolator(interpolator).alpha(1.0f).get());
}
if (anims.isEmpty()) {
return;
}
AnimatorSet animSet = new AnimatorSet();
if (!withAnim) {
// temporary, from laziness
animSet.setDuration(0);
}
animSet.playTogether(anims.toArray(new ObjectAnimator[anims.size()]));
animSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (mOnVisibleWidthChangedListener != null) {
mVisibleWidth = (getChildCount() * (int) ACTION_DIMENSION_PX) - (mHasOverflow ? Util.dpToPx(8) : 0);
mOnVisibleWidthChangedListener.onItemsMenuVisibleWidthChanged(mVisibleWidth);
}
}
});
animSet.start();
}
use of android.view.animation.Interpolator in project httpclient by pixmob.
the class KeyframeSet method getValue.
/**
* Gets the animated value, given the elapsed fraction of the animation (interpolated by the
* animation's interpolator) and the evaluator used to calculate in-between values. This
* function maps the input fraction to the appropriate keyframe interval and a fraction
* between them and returns the interpolated value. Note that the input fraction may fall
* outside the [0-1] bounds, if the animation's interpolator made that happen (e.g., a
* spring interpolation that might send the fraction past 1.0). We handle this situation by
* just using the two keyframes at the appropriate end when the value is outside those bounds.
*
* @param fraction The elapsed fraction of the animation
* @return The animated value.
*/
public Object getValue(float fraction) {
// Special-case optimization for the common case of only two keyframes
if (mNumKeyframes == 2) {
if (mInterpolator != null) {
fraction = mInterpolator.getInterpolation(fraction);
}
return mEvaluator.evaluate(fraction, mFirstKeyframe.getValue(), mLastKeyframe.getValue());
}
if (fraction <= 0f) {
final Keyframe nextKeyframe = mKeyframes.get(1);
final Interpolator /*Time*/
interpolator = nextKeyframe.getInterpolator();
if (interpolator != null) {
fraction = interpolator.getInterpolation(fraction);
}
final float prevFraction = mFirstKeyframe.getFraction();
float intervalFraction = (fraction - prevFraction) / (nextKeyframe.getFraction() - prevFraction);
return mEvaluator.evaluate(intervalFraction, mFirstKeyframe.getValue(), nextKeyframe.getValue());
} else if (fraction >= 1f) {
final Keyframe prevKeyframe = mKeyframes.get(mNumKeyframes - 2);
final Interpolator /*Time*/
interpolator = mLastKeyframe.getInterpolator();
if (interpolator != null) {
fraction = interpolator.getInterpolation(fraction);
}
final float prevFraction = prevKeyframe.getFraction();
float intervalFraction = (fraction - prevFraction) / (mLastKeyframe.getFraction() - prevFraction);
return mEvaluator.evaluate(intervalFraction, prevKeyframe.getValue(), mLastKeyframe.getValue());
}
Keyframe prevKeyframe = mFirstKeyframe;
for (int i = 1; i < mNumKeyframes; ++i) {
Keyframe nextKeyframe = mKeyframes.get(i);
if (fraction < nextKeyframe.getFraction()) {
final Interpolator /*Time*/
interpolator = nextKeyframe.getInterpolator();
if (interpolator != null) {
fraction = interpolator.getInterpolation(fraction);
}
final float prevFraction = prevKeyframe.getFraction();
float intervalFraction = (fraction - prevFraction) / (nextKeyframe.getFraction() - prevFraction);
return mEvaluator.evaluate(intervalFraction, prevKeyframe.getValue(), nextKeyframe.getValue());
}
prevKeyframe = nextKeyframe;
}
// shouldn't reach here
return mLastKeyframe.getValue();
}
use of android.view.animation.Interpolator in project android_packages_apps_Settings by LineageOS.
the class PreviewPagerAdapter method setVisibility.
private void setVisibility(final View view, final int visibility, boolean animate) {
final float alpha = (visibility == View.VISIBLE ? 1.0f : 0.0f);
if (!animate) {
view.setAlpha(alpha);
view.setVisibility(visibility);
} else {
final Interpolator interpolator = (visibility == View.VISIBLE ? FADE_IN_INTERPOLATOR : FADE_OUT_INTERPOLATOR);
if (visibility == View.VISIBLE) {
// Fade in animation.
view.animate().alpha(alpha).setInterpolator(FADE_IN_INTERPOLATOR).setDuration(CROSS_FADE_DURATION_MS).setListener(new PreviewFrameAnimatorListener()).withStartAction(new Runnable() {
@Override
public void run() {
view.setVisibility(visibility);
}
});
} else {
// Fade out animation.
view.animate().alpha(alpha).setInterpolator(FADE_OUT_INTERPOLATOR).setDuration(CROSS_FADE_DURATION_MS).setListener(new PreviewFrameAnimatorListener()).withEndAction(new Runnable() {
@Override
public void run() {
view.setVisibility(visibility);
}
});
}
}
}
use of android.view.animation.Interpolator in project weiui by kuaifan.
the class RxAnimationTool method cardFilpAnimation.
/**
* 卡片翻转动画
*
* @param beforeView
* @param AfterView
*/
public static void cardFilpAnimation(final View beforeView, final View AfterView) {
Interpolator accelerator = new AccelerateInterpolator();
Interpolator decelerator = new DecelerateInterpolator();
if (beforeView.getVisibility() == View.GONE) {
// 局部layout可达到字体翻转 背景不翻转
invisToVis = ObjectAnimator.ofFloat(beforeView, "rotationY", -90f, 0f);
visToInvis = ObjectAnimator.ofFloat(AfterView, "rotationY", 0f, 90f);
} else if (AfterView.getVisibility() == View.GONE) {
invisToVis = ObjectAnimator.ofFloat(AfterView, "rotationY", -90f, 0f);
visToInvis = ObjectAnimator.ofFloat(beforeView, "rotationY", 0f, 90f);
}
// 翻转速度
visToInvis.setDuration(250);
// 在动画开始的地方速率改变比较慢,然后开始加速
visToInvis.setInterpolator(accelerator);
invisToVis.setDuration(250);
invisToVis.setInterpolator(decelerator);
visToInvis.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationEnd(Animator arg0) {
if (beforeView.getVisibility() == View.GONE) {
AfterView.setVisibility(View.GONE);
invisToVis.start();
beforeView.setVisibility(View.VISIBLE);
} else {
AfterView.setVisibility(View.GONE);
visToInvis.start();
beforeView.setVisibility(View.VISIBLE);
}
}
@Override
public void onAnimationCancel(Animator arg0) {
}
@Override
public void onAnimationRepeat(Animator arg0) {
}
@Override
public void onAnimationStart(Animator arg0) {
}
});
visToInvis.start();
}
use of android.view.animation.Interpolator in project android_packages_apps_Dialer by LineageOS.
the class VideoCallFragment method enterFullscreenMode.
private void enterFullscreenMode() {
LogUtil.i("VideoCallFragment.enterFullscreenMode", null);
hideSystemUI();
Interpolator fastOutLinearInInterpolator = new FastOutLinearInInterpolator();
// Animate controls to the hidden state.
Point offset = getControlsOffsetEndHidden(controls);
controls.animate().translationX(offset.x).translationY(offset.y).setInterpolator(fastOutLinearInInterpolator).alpha(0).start();
// Animate onHold to the hidden state.
offset = getSwitchOnHoldOffsetEndHidden(switchOnHoldButton);
switchOnHoldButton.animate().translationX(offset.x).translationY(offset.y).setInterpolator(fastOutLinearInInterpolator).alpha(0);
View contactGridView = contactGridManager.getContainerView();
// Animate contact grid to the hidden state.
offset = getContactGridOffsetEndHidden(contactGridView);
contactGridView.animate().translationX(offset.x).translationY(offset.y).setInterpolator(fastOutLinearInInterpolator).alpha(0);
offset = getEndCallOffsetEndHidden(endCallButton);
// Use a fast out interpolator to quickly fade out the button. This is important because the
// button can't draw under the navigation bar which means that it'll look weird if it just
// abruptly disappears when it reaches the edge of the naivgation bar.
endCallButton.animate().translationX(offset.x).translationY(offset.y).setInterpolator(fastOutLinearInInterpolator).alpha(0).withEndAction(new Runnable() {
@Override
public void run() {
endCallButton.setVisibility(View.INVISIBLE);
}
}).setInterpolator(new FastOutLinearInInterpolator()).start();
// a fixed position.
if (!isInGreenScreenMode) {
for (View view : getAllPreviewRelatedViews()) {
// Animate down with the navigation bar hidden.
view.animate().translationX(0).translationY(0).setInterpolator(new AccelerateDecelerateInterpolator()).start();
}
}
updateOverlayBackground();
}
Aggregations