use of android.view.animation.Animation in project material-components-android by material-components.
the class BaseTransientBottomBar method animateViewIn.
void animateViewIn() {
if (Build.VERSION.SDK_INT >= 12) {
final int viewHeight = mView.getHeight();
if (USE_OFFSET_API) {
ViewCompat.offsetTopAndBottom(mView, viewHeight);
} else {
ViewCompat.setTranslationY(mView, viewHeight);
}
final ValueAnimatorCompat animator = ViewUtils.createAnimator();
animator.setIntValues(viewHeight, 0);
animator.setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR);
animator.setDuration(ANIMATION_DURATION);
animator.addListener(new ValueAnimatorCompat.AnimatorListenerAdapter() {
@Override
public void onAnimationStart(ValueAnimatorCompat animator) {
mContentViewCallback.animateContentIn(ANIMATION_DURATION - ANIMATION_FADE_DURATION, ANIMATION_FADE_DURATION);
}
@Override
public void onAnimationEnd(ValueAnimatorCompat animator) {
onViewShown();
}
});
animator.addUpdateListener(new ValueAnimatorCompat.AnimatorUpdateListener() {
private int previousAnimatedIntValue = viewHeight;
@Override
public void onAnimationUpdate(ValueAnimatorCompat animator) {
int currentAnimatedIntValue = animator.getAnimatedIntValue();
if (USE_OFFSET_API) {
// On JB versions of the platform sometimes View.setTranslationY does not
// result in layout / draw pass
ViewCompat.offsetTopAndBottom(mView, currentAnimatedIntValue - previousAnimatedIntValue);
} else {
ViewCompat.setTranslationY(mView, currentAnimatedIntValue);
}
previousAnimatedIntValue = currentAnimatedIntValue;
}
});
animator.start();
} else {
final Animation anim = AnimationUtils.loadAnimation(mView.getContext(), R.anim.design_snackbar_in);
anim.setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR);
anim.setDuration(ANIMATION_DURATION);
anim.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationEnd(Animation animation) {
onViewShown();
}
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
mView.startAnimation(anim);
}
}
use of android.view.animation.Animation in project material-components-android by material-components.
the class BaseTransientBottomBar method animateViewOut.
private void animateViewOut(final int event) {
if (Build.VERSION.SDK_INT >= 12) {
final ValueAnimatorCompat animator = ViewUtils.createAnimator();
animator.setIntValues(0, mView.getHeight());
animator.setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR);
animator.setDuration(ANIMATION_DURATION);
animator.addListener(new ValueAnimatorCompat.AnimatorListenerAdapter() {
@Override
public void onAnimationStart(ValueAnimatorCompat animator) {
mContentViewCallback.animateContentOut(0, ANIMATION_FADE_DURATION);
}
@Override
public void onAnimationEnd(ValueAnimatorCompat animator) {
onViewHidden(event);
}
});
animator.addUpdateListener(new ValueAnimatorCompat.AnimatorUpdateListener() {
private int previousAnimatedIntValue = 0;
@Override
public void onAnimationUpdate(ValueAnimatorCompat animator) {
int currentAnimatedIntValue = animator.getAnimatedIntValue();
if (USE_OFFSET_API) {
// On JB versions of the platform sometimes View.setTranslationY does not
// result in layout / draw pass
ViewCompat.offsetTopAndBottom(mView, currentAnimatedIntValue - previousAnimatedIntValue);
} else {
ViewCompat.setTranslationY(mView, currentAnimatedIntValue);
}
previousAnimatedIntValue = currentAnimatedIntValue;
}
});
animator.start();
} else {
final Animation anim = AnimationUtils.loadAnimation(mView.getContext(), R.anim.design_snackbar_out);
anim.setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR);
anim.setDuration(ANIMATION_DURATION);
anim.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationEnd(Animation animation) {
onViewHidden(event);
}
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
mView.startAnimation(anim);
}
}
use of android.view.animation.Animation in project robolectric by robolectric.
the class ShadowViewTest method startAnimation.
@Test
public void startAnimation() {
TestView view = new TestView(buildActivity(Activity.class).create().get());
AlphaAnimation animation = new AlphaAnimation(0, 1);
Animation.AnimationListener listener = mock(Animation.AnimationListener.class);
animation.setAnimationListener(listener);
view.startAnimation(animation);
verify(listener).onAnimationStart(animation);
verify(listener).onAnimationEnd(animation);
}
use of android.view.animation.Animation in project robolectric by robolectric.
the class ShadowViewTest method shouldSetAnimation.
@Test
public void shouldSetAnimation() throws Exception {
Animation anim = new TestAnimation();
view.setAnimation(anim);
assertThat(view.getAnimation()).isSameAs(anim);
}
use of android.view.animation.Animation in project robolectric by robolectric.
the class ShadowViewTest method setAnimation.
@Test
public void setAnimation() {
TestView view = new TestView(buildActivity(Activity.class).create().get());
AlphaAnimation animation = new AlphaAnimation(0, 1);
Animation.AnimationListener listener = mock(Animation.AnimationListener.class);
animation.setAnimationListener(listener);
animation.setStartTime(1000);
view.setAnimation(animation);
verifyZeroInteractions(listener);
Robolectric.getForegroundThreadScheduler().advanceToNextPostedRunnable();
verify(listener).onAnimationStart(animation);
verify(listener).onAnimationEnd(animation);
}
Aggregations