Search in sources :

Example 21 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project ListViewAnimations by nhaarman.

the class SwipeTouchListener method flingView.

/**
     * Flings given {@link android.view.View} out of sight.
     *
     * @param view         the parent {@link android.view.View}.
     * @param position     the position of the item in the {@link android.widget.ListAdapter} corresponding to the {@code View}.
     * @param flingToRight {@code true} if the {@code View} should be flinged to the right, {@code false} if it should be flinged to the left.
     */
private void flingView(@NonNull final View view, final int position, final boolean flingToRight) {
    if (mViewWidth < 2) {
        mViewWidth = mListViewWrapper.getListView().getWidth();
    }
    View swipeView = getSwipeView(view);
    ObjectAnimator xAnimator = ObjectAnimator.ofFloat(swipeView, TRANSLATION_X, flingToRight ? mViewWidth : -mViewWidth);
    ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(swipeView, ALPHA, 0);
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(xAnimator, alphaAnimator);
    animatorSet.setDuration(mAnimationTime);
    animatorSet.addListener(new FlingAnimatorListener(view, position));
    animatorSet.start();
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) AnimatorSet(com.nineoldandroids.animation.AnimatorSet) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 22 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project ListViewAnimations by nhaarman.

the class SwipeUndoTouchListener method undo.

/**
     * Performs the undo animation and restores the original state for given {@link android.view.View}.
     *
     * @param view the parent {@code View} which contains both primary and undo {@code View}s.
     */
public void undo(@NonNull final View view) {
    int position = AdapterViewUtil.getPositionForView(getListViewWrapper(), view);
    mUndoPositions.remove(position);
    View primaryView = mCallback.getPrimaryView(view);
    View undoView = mCallback.getUndoView(view);
    primaryView.setVisibility(View.VISIBLE);
    ObjectAnimator undoAlphaAnimator = ObjectAnimator.ofFloat(undoView, ALPHA, 1f, 0f);
    ObjectAnimator primaryAlphaAnimator = ObjectAnimator.ofFloat(primaryView, ALPHA, 0f, 1f);
    ObjectAnimator primaryXAnimator = ObjectAnimator.ofFloat(primaryView, TRANSLATION_X, primaryView.getWidth(), 0f);
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(undoAlphaAnimator, primaryAlphaAnimator, primaryXAnimator);
    animatorSet.addListener(new UndoAnimatorListener(undoView));
    animatorSet.start();
    mCallback.onUndo(view, position);
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) AnimatorSet(com.nineoldandroids.animation.AnimatorSet) View(android.view.View)

Example 23 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project ListViewAnimations by nhaarman.

the class ScaleInAnimationAdapter method getAnimators.

@NonNull
@Override
public Animator[] getAnimators(@NonNull final ViewGroup parent, @NonNull final View view) {
    ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, SCALE_X, mScaleFrom, 1f);
    ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, SCALE_Y, mScaleFrom, 1f);
    return new ObjectAnimator[] { scaleX, scaleY };
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) NonNull(android.support.annotation.NonNull)

Example 24 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project MinimalForm by sd6352051.

the class MinimalFormLayout method resetLayout.

private void resetLayout(String title) {
    ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(mLabelTitle, "translationY", 0, -mLabelTitle.getHeight()).setDuration(ANIMATION_DURATION / 2);
    objectAnimator.addListener(this);
    objectAnimator.start();
    mEditText.setText(contents[currentStep]);
    if (inputTypes != null) {
        mEditText.setInputType(inputTypes.get(currentStep));
    }
    mTextPage.setText((currentStep + 1) + "/" + datasize);
    mEditText.setSelection(contents[currentStep] == null ? 0 : contents[currentStep].length());
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator)

Example 25 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project BeautifulRefreshLayout by android-cjj.

the class BeautifulRefreshLayout method shakeAnim.

public void shakeAnim(View view) {
    ObjectAnimator animator = ObjectAnimator.ofFloat(view, "rotation", 0, 2, 0, -2, 0);
    animator.setDuration(100);
    animator.setRepeatCount(-1);
    animator.setRepeatMode(ValueAnimator.RESTART);
    animator.start();
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator)

Aggregations

ObjectAnimator (com.nineoldandroids.animation.ObjectAnimator)81 AnimatorSet (com.nineoldandroids.animation.AnimatorSet)27 Animator (com.nineoldandroids.animation.Animator)20 View (android.view.View)11 PropertyValuesHolder (com.nineoldandroids.animation.PropertyValuesHolder)10 Keyframe (com.nineoldandroids.animation.Keyframe)9 Paint (android.graphics.Paint)8 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)8 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)6 TextView (android.widget.TextView)5 AdapterView (android.widget.AdapterView)4 AnimatorListenerAdapter (com.nineoldandroids.animation.AnimatorListenerAdapter)4 SuppressLint (android.annotation.SuppressLint)3 TargetApi (android.annotation.TargetApi)3 LinearInterpolator (android.view.animation.LinearInterpolator)3 OvershootInterpolator (android.view.animation.OvershootInterpolator)3 AbsListView (android.widget.AbsListView)3 ListView (android.widget.ListView)3 ValueAnimator (com.nineoldandroids.animation.ValueAnimator)3 SupportAnimator (io.codetail.animation.SupportAnimator)3