use of android.animation.ArgbEvaluator in project BottomBar by roughike.
the class BottomBarTab method animateColors.
private void animateColors(int previousColor, int color) {
ValueAnimator anim = new ValueAnimator();
anim.setIntValues(previousColor, color);
anim.setEvaluator(new ArgbEvaluator());
anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
setColors((Integer) valueAnimator.getAnimatedValue());
}
});
anim.setDuration(150);
anim.start();
}
use of android.animation.ArgbEvaluator in project android-app by spark.
the class Pin method animateYourself.
public void animateYourself() {
final ViewGroup parent = (ViewGroup) view.getParent();
if (pinBackgroundAnim != null) {
pinBackgroundAnim.end();
pinBackgroundAnim = null;
}
pinBackgroundAnim = (ObjectAnimator) AnimatorInflater.loadAnimator(view.getContext(), R.animator.pin_background_start);
pinBackgroundAnim.setTarget(parent);
pinBackgroundAnim.setEvaluator(new ArgbEvaluator());
pinBackgroundAnim.addListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
// NO OP
}
@Override
public void onAnimationRepeat(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
}
@Override
public void onAnimationCancel(Animator animation) {
endAnimation = getCancelAnimator();
endAnimation.start();
}
});
pinBackgroundAnim.start();
}
use of android.animation.ArgbEvaluator in project boilerplate by koush.
the class DrawerActivity method resetDrawerToggle.
private void resetDrawerToggle() {
getDrawer().setDrawerListener(drawerToggle = new ActionBarDrawerToggle(this, getDrawer(), getDrawerOpenString(), getDrawerCloseString()) {
// DecelerateInterpolator interpolator = new DecelerateInterpolator();
ArgbEvaluator evaluator = new ArgbEvaluator();
boolean hasOpened;
int originalStatusBarColor;
@Override
public void onDrawerStateChanged(int newState) {
super.onDrawerStateChanged(newState);
if (newState == DrawerLayout.STATE_DRAGGING && !hasOpened) {
hasOpened = true;
originalStatusBarColor = WindowChromeUtils.getStatusBarColor(getWindow());
}
}
@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
super.onDrawerSlide(drawerView, slideOffset);
// and don't erroneously translate this stuff.
if (!getDrawer().isDrawerVisible(Gravity.LEFT))
return;
// View content = getDrawer().getChildAt(0);
// View drawer = getDrawer().getChildAt(1);
// content.setTranslationX(Math.min(content.getMeasuredWidth(), drawer.getMeasuredWidth()) / 3 * interpolator.getInterpolation(slideOffset));
onDrawerOpen();
if (hasOpened)
WindowChromeUtils.setStatusBarColor(getWindow(), (int) evaluator.evaluate(slideOffset, originalStatusBarColor, 0x4D000000));
}
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
if (hasOpened) {
WindowChromeUtils.setStatusBarColor(getWindow(), originalStatusBarColor);
}
if (isFinishing())
return;
DrawerActivity.this.onDrawerClosed();
}
});
drawerToggle.syncState();
}
use of android.animation.ArgbEvaluator in project boilerplate by koush.
the class ScrollingToolbarLayout method toolbarFadeToColor.
void toolbarFadeToColor(int color) {
if (existingToolbarColorAnimation != null)
existingToolbarColorAnimation.cancel();
View toolbarContainer = getChildAt(getChildCount() - 1);
int existingColor = ((ColorDrawable) toolbarContainer.getBackground()).getColor();
existingToolbarColorAnimation = ObjectAnimator.ofInt(toolbarContainer, "backgroundColor", existingColor, color);
existingToolbarColorAnimation.setEvaluator(new ArgbEvaluator());
existingToolbarColorAnimation.setDuration(500);
existingToolbarColorAnimation.start();
}
use of android.animation.ArgbEvaluator in project Rutgers-Course-Tracker by tevjef.
the class SectionInfoFragment method showSectionTracked.
@Override
public void showSectionTracked(boolean sectionIsAdded, boolean shouldAnimateView) {
final int COLOR = ContextCompat.getColor(getParentActivity(), R.color.accent);
final int COLOR_DARK = ContextCompat.getColor(getParentActivity(), R.color.accent_dark);
final int ROTATION_NORMAL = 0;
final int ROTATION_ADDED = 225;
final int DURATION = 500;
if (shouldAnimateView) {
if (sectionIsAdded != mViewState.isSectionAdded) {
ViewCompat.animate(mFab).setDuration(DURATION).setInterpolator(new DecelerateInterpolator()).rotation(sectionIsAdded ? ROTATION_ADDED : ROTATION_NORMAL);
//I would much prefer to animate from the current coolor to the next but the fab has
// no method to get the current color and I'm not desparate enough to manage it myself.
// As for now, the fab will only animate on user click. Not from a db update.
ValueAnimator colorAnim = ObjectAnimator.ofInt(this, "backgroundColor", sectionIsAdded ? COLOR : COLOR_DARK, sectionIsAdded ? COLOR_DARK : COLOR);
colorAnim.setDuration(500);
colorAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
if (mFab != null)
mFab.setBackgroundTintList(ColorStateList.valueOf((Integer) animation.getAnimatedValue()));
}
});
colorAnim.setEvaluator(new ArgbEvaluator());
colorAnim.start();
}
} else {
//Using ViewCompat to set the tint list is bugged on pre lollipop.
mFab.setBackgroundTintList(ColorStateList.valueOf(sectionIsAdded ? COLOR_DARK : COLOR));
ViewCompat.setRotation(mFab, sectionIsAdded ? ROTATION_ADDED : ROTATION_NORMAL);
}
mViewState.isSectionAdded = sectionIsAdded;
}
Aggregations