use of com.nineoldandroids.animation.ValueAnimator in project Android-ObservableScrollView by ksoichiro.
the class ViewPagerTab2Activity method animateToolbar.
private void animateToolbar(final float toY) {
float layoutTranslationY = ViewHelper.getTranslationY(mInterceptionLayout);
if (layoutTranslationY != toY) {
ValueAnimator animator = ValueAnimator.ofFloat(ViewHelper.getTranslationY(mInterceptionLayout), toY).setDuration(200);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float translationY = (float) animation.getAnimatedValue();
ViewHelper.setTranslationY(mInterceptionLayout, translationY);
if (translationY < 0) {
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mInterceptionLayout.getLayoutParams();
lp.height = (int) (-translationY + getScreenHeight());
mInterceptionLayout.requestLayout();
}
}
});
animator.start();
}
}
use of com.nineoldandroids.animation.ValueAnimator in project Android-ObservableScrollView by ksoichiro.
the class SlidingUpBaseActivity method changeHeaderBarColorAnimated.
private void changeHeaderBarColorAnimated(boolean animated) {
if (mHeaderColorIsChanging) {
return;
}
boolean shouldBeWhite = getAnchorYBottom() == ViewHelper.getTranslationY(mInterceptionLayout);
if (!mHeaderIsAtBottom && !mHeaderColorChangedToBottom && shouldBeWhite) {
mHeaderIsAtBottom = true;
mHeaderIsNotAtBottom = false;
if (animated) {
ValueAnimator animator = ValueAnimator.ofFloat(0, 1).setDuration(100);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float alpha = (float) animation.getAnimatedValue();
mHeaderColorIsChanging = (alpha != 1);
changeHeaderBarColor(alpha);
}
});
animator.start();
} else {
changeHeaderBarColor(1);
}
} else if (!mHeaderIsNotAtBottom && !shouldBeWhite) {
mHeaderIsAtBottom = false;
mHeaderIsNotAtBottom = true;
if (animated) {
ValueAnimator animator = ValueAnimator.ofFloat(1, 0).setDuration(100);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float alpha = (float) animation.getAnimatedValue();
mHeaderColorIsChanging = (alpha != 0);
changeHeaderBarColor(alpha);
}
});
animator.start();
} else {
changeHeaderBarColor(0);
}
}
}
use of com.nineoldandroids.animation.ValueAnimator in project Android-ObservableScrollView by ksoichiro.
the class SlidingUpBaseActivity method slideWithAnimation.
private void slideWithAnimation(float toY) {
float layoutTranslationY = ViewHelper.getTranslationY(mInterceptionLayout);
if (layoutTranslationY != toY) {
ValueAnimator animator = ValueAnimator.ofFloat(ViewHelper.getTranslationY(mInterceptionLayout), toY).setDuration(200);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
slideTo((float) animation.getAnimatedValue(), true);
}
});
animator.start();
}
}
use of com.nineoldandroids.animation.ValueAnimator in project Android-ObservableScrollView by ksoichiro.
the class ViewPagerTab2Activity method animateToolbar.
private void animateToolbar(final float toY) {
float layoutTranslationY = ViewHelper.getTranslationY(mInterceptionLayout);
if (layoutTranslationY != toY) {
ValueAnimator animator = ValueAnimator.ofFloat(ViewHelper.getTranslationY(mInterceptionLayout), toY).setDuration(200);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float translationY = (float) animation.getAnimatedValue();
ViewHelper.setTranslationY(mInterceptionLayout, translationY);
if (translationY < 0) {
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mInterceptionLayout.getLayoutParams();
lp.height = (int) (-translationY + getScreenHeight());
mInterceptionLayout.requestLayout();
}
}
});
animator.start();
}
}
use of com.nineoldandroids.animation.ValueAnimator in project Android-ObservableScrollView by ksoichiro.
the class FillGapBaseActivity method changeHeaderBackgroundHeightAnimated.
private void changeHeaderBackgroundHeightAnimated(boolean shouldShowGap, boolean animated) {
if (mGapIsChanging) {
return;
}
final int heightOnGapShown = mHeaderBar.getHeight();
final int heightOnGapHidden = mHeaderBar.getHeight() + mActionBarSize;
final float from = mHeaderBackground.getLayoutParams().height;
final float to;
if (shouldShowGap) {
if (!mGapHidden) {
// Already shown
return;
}
to = heightOnGapShown;
} else {
if (mGapHidden) {
// Already hidden
return;
}
to = heightOnGapHidden;
}
if (animated) {
ViewPropertyAnimator.animate(mHeaderBackground).cancel();
ValueAnimator a = ValueAnimator.ofFloat(from, to);
a.setDuration(100);
a.setInterpolator(new AccelerateDecelerateInterpolator());
a.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float height = (float) animation.getAnimatedValue();
changeHeaderBackgroundHeight(height, to, heightOnGapHidden);
}
});
a.start();
} else {
changeHeaderBackgroundHeight(to, to, heightOnGapHidden);
}
}
Aggregations