Java Code Examples for com.nineoldandroids.animation.ValueAnimator#setInterpolator()

The following examples show how to use com.nineoldandroids.animation.ValueAnimator#setInterpolator() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PopBackgroundView.java    From AndroidColorPop with Apache License 2.0 6 votes vote down vote up
/**
 * Internal void to start the circles animation.
 * <p>
 * when this void is called the circles radius would be updated by a
 * {@link ValueAnimator} and then it will call the {@link View}'s
 * invalidate() void witch calls the onDraw void each time so a bigger
 * circle would be drawn each time till the cirlce's fill the whole screen.
 * </p>
 */
private void animateCirlce() {
	if (circles_fill_type == CIRLCES_FILL_HEIGHT_TYPE) {
		circle_max_radius = screen_height + (screen_height / 4);
	} else {
		circle_max_radius = screen_width + (screen_width / 4);
	}
	ValueAnimator va = ValueAnimator.ofInt(0, circle_max_radius / 3);
	va.setDuration(1000);
	va.addListener(this);
	va.setInterpolator(new AccelerateInterpolator());
	va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
		public void onAnimationUpdate(ValueAnimator animation) {
			int value = (int) animation.getAnimatedValue();
			circle_radius = value * 3;
			invalidate();
		}
	});
	va.start();
}
 
Example 2
Source File: PopBackgroundView.java    From AndroidColorPop with Apache License 2.0 6 votes vote down vote up
/**
 * Internal void to start the rectangle animation.
 * <p>
 * when this void is called the space at the top of the rectangle would be
 * updated by a {@link ValueAnimator} and then it will call the {@link View}
 * 's invalidate() void witch calls the onDraw void each time so a bigger
 * rectangle would be drawn each time till the it the rectangles height is
 * enough
 * </p>
 */
private void animateRect() {
	ValueAnimator va = ValueAnimator.ofInt(rect_space_top / 2,
			screen_height / 2);
	va.setDuration(500);
	va.addListener(this);
	va.setInterpolator(new DecelerateInterpolator());
	va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
		public void onAnimationUpdate(ValueAnimator animation) {
			int value = ((int) animation.getAnimatedValue()) * 2;
			int rect_top = -((value - rect_space_top) - screen_height);
			rect.top = rect_top;
			invalidate();
		}
	});
	va.start();
}
 
Example 3
Source File: PullToNextView.java    From Android-PullToNextLayout with Apache License 2.0 6 votes vote down vote up
public void moveTo(final float i, int duration) {
    int topMargin = getHeaderTopMargin();
    ValueAnimator animator = ValueAnimator.ofFloat(topMargin, i);
    animator.setDuration(duration);
    animator.setInterpolator(new DecelerateInterpolator());
    mPullStateE = PullStateE.PULL_STATE_NONE;
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {


        @TargetApi(Build.VERSION_CODES.HONEYCOMB)
        public void onAnimationUpdate(ValueAnimator valueAnimator) {

            float temp = (Float) valueAnimator.getAnimatedValue();

            if (temp == i) {
                mPullStateE = PullStateE.PULL_STATE_NONE;
            }
            setHeaderTopMargin((int) temp);
        }
    });
    animator.start();
}
 
Example 4
Source File: ViewPropertyAnimatorHC.java    From Mover with Apache License 2.0 6 votes vote down vote up
/**
 * Starts the underlying Animator for a set of properties. We use a single animator that
 * simply runs from 0 to 1, and then use that fractional value to set each property
 * value accordingly.
 */
private void startAnimation() {
    ValueAnimator animator = ValueAnimator.ofFloat(1.0f);
    ArrayList<NameValuesHolder> nameValueList =
            (ArrayList<NameValuesHolder>) mPendingAnimations.clone();
    mPendingAnimations.clear();
    int propertyMask = 0;
    int propertyCount = nameValueList.size();
    for (int i = 0; i < propertyCount; ++i) {
        NameValuesHolder nameValuesHolder = nameValueList.get(i);
        propertyMask |= nameValuesHolder.mNameConstant;
    }
    mAnimatorMap.put(animator, new PropertyBundle(propertyMask, nameValueList));
    animator.addUpdateListener(mAnimatorEventListener);
    animator.addListener(mAnimatorEventListener);
    if (mStartDelaySet) {
        animator.setStartDelay(mStartDelay);
    }
    if (mDurationSet) {
        animator.setDuration(mDuration);
    }
    if (mInterpolatorSet) {
        animator.setInterpolator(mInterpolator);
    }
    animator.start();
}
 
Example 5
Source File: ViewPropertyAnimatorPreHC.java    From Mover with Apache License 2.0 6 votes vote down vote up
/**
 * Starts the underlying Animator for a set of properties. We use a single animator that
 * simply runs from 0 to 1, and then use that fractional value to set each property
 * value accordingly.
 */
private void startAnimation() {
    ValueAnimator animator = ValueAnimator.ofFloat(1.0f);
    ArrayList<NameValuesHolder> nameValueList =
            (ArrayList<NameValuesHolder>) mPendingAnimations.clone();
    mPendingAnimations.clear();
    int propertyMask = 0;
    int propertyCount = nameValueList.size();
    for (int i = 0; i < propertyCount; ++i) {
        NameValuesHolder nameValuesHolder = nameValueList.get(i);
        propertyMask |= nameValuesHolder.mNameConstant;
    }
    mAnimatorMap.put(animator, new PropertyBundle(propertyMask, nameValueList));
    animator.addUpdateListener(mAnimatorEventListener);
    animator.addListener(mAnimatorEventListener);
    if (mStartDelaySet) {
        animator.setStartDelay(mStartDelay);
    }
    if (mDurationSet) {
        animator.setDuration(mDuration);
    }
    if (mInterpolatorSet) {
        animator.setInterpolator(mInterpolator);
    }
    animator.start();
}
 
Example 6
Source File: AnimatedDrawable.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
@Override
public ValueAnimator createValueAnimator() {
  int loopCount = mAnimatedDrawableBackend.getLoopCount();
  ValueAnimator animator = new ValueAnimator();
  animator.setIntValues(0, mDurationMs);
  animator.setDuration(mDurationMs);
  animator.setRepeatCount(loopCount != 0 ? loopCount : ValueAnimator.INFINITE);
  animator.setRepeatMode(ValueAnimator.RESTART);
  animator.setInterpolator(new LinearInterpolator());
  animator.addUpdateListener(createAnimatorUpdateListener());
  return animator;
}
 
Example 7
Source File: TransferControlView.java    From Silence with GNU General Public License v3.0 5 votes vote down vote up
private Animator getWidthAnimator(final int from, final int to) {
  final ValueAnimator anim = ValueAnimator.ofInt(from, to);
  anim.addUpdateListener(new AnimatorUpdateListener() {
    @Override
    public void onAnimationUpdate(ValueAnimator animation) {
      final int val = (Integer)animation.getAnimatedValue();
      final ViewGroup.LayoutParams layoutParams = getLayoutParams();
      layoutParams.width = val;
      setLayoutParams(layoutParams);
    }
  });
  anim.setInterpolator(new FastOutSlowInInterpolator());
  anim.setDuration(TRANSITION_MS);
  return anim;
}
 
Example 8
Source File: RoundProgressBar.java    From Conquer with Apache License 2.0 5 votes vote down vote up
/**
     * 设置进度,此为线程安全控件,由于考虑多线的问题,需要同步 刷新界面调用postInvalidate()能在非UI线程刷新
     *
     * @param progress
     */

    public synchronized void setProgress(int progress) {
        if (this.progress == progress) {
            return;
        }

//        hasShowing = true;
        if (progress < 0) {
//			throw new IllegalArgumentException("progress not less than 0");
            return;
        }
        if (progress > max) {
            progress = max;
        }
        ValueAnimator va = ValueAnimator.ofInt(this.progress, progress);
        va.setDuration(1000);
        va.setInterpolator(new AccelerateInterpolator());
        va.start();
        va.addUpdateListener(new AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator arg0) {
                int value = (Integer) arg0.getAnimatedValue();
                if (value <= max) {
                    RoundProgressBar.this.progress = value;
                    invalidate();
                }
            }
        });

    }
 
Example 9
Source File: i.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
private void a()
{
    ValueAnimator valueanimator = ValueAnimator.ofFloat(new float[] {
        1.0F
    });
    ArrayList arraylist = (ArrayList)a.clone();
    a.clear();
    int i1 = arraylist.size();
    int j1 = 0;
    int k1 = 0;
    do
    {
        if (j1 >= i1)
        {
            y.put(valueanimator, new m(k1, arraylist));
            valueanimator.addUpdateListener(k);
            valueanimator.addListener(k);
            if (g)
            {
                valueanimator.setStartDelay(f);
            }
            if (e)
            {
                valueanimator.setDuration(d);
            }
            if (i)
            {
                valueanimator.setInterpolator(h);
            }
            valueanimator.start();
            return;
        }
        k1 |= ((l)arraylist.get(j1)).a;
        j1++;
    } while (true);
}
 
Example 10
Source File: b.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
private void a()
{
    ValueAnimator valueanimator = ValueAnimator.ofFloat(new float[] {
        1.0F
    });
    ArrayList arraylist = (ArrayList)a.clone();
    a.clear();
    int i1 = arraylist.size();
    int j1 = 0;
    int k1 = 0;
    do
    {
        if (j1 >= i1)
        {
            x.put(valueanimator, new f(k1, arraylist));
            valueanimator.addUpdateListener(j);
            valueanimator.addListener(j);
            if (f)
            {
                valueanimator.setStartDelay(e);
            }
            if (d)
            {
                valueanimator.setDuration(c);
            }
            if (h)
            {
                valueanimator.setInterpolator(g);
            }
            valueanimator.start();
            return;
        }
        k1 |= ((e)arraylist.get(j1)).a;
        j1++;
    } while (true);
}
 
Example 11
Source File: LrcView.java    From DMusic with Apache License 2.0 4 votes vote down vote up
private void initAnim() {
    mAnimation = new ValueAnimator();
    mAnimation.setInterpolator(new LinearInterpolator());
    mAnimation.addUpdateListener(new UpdateListener(this));
}