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

The following examples show how to use com.nineoldandroids.animation.ValueAnimator#start() . 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: SwipeDismissListViewTouchListener.java    From android-open-project-demo with Apache License 2.0 6 votes vote down vote up
protected void performDismiss(final PendingDismissData data) {
    // Animate the dismissed list item to zero-height and fire the
    // dismiss callback when all dismissed list item animations have
    // completed.

    final ViewGroup.LayoutParams lp = data.view.getLayoutParams();
    final int originalHeight = data.view.getHeight();

    ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mAnimationTime);

    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(final ValueAnimator valueAnimator) {
            lp.height = (Integer) valueAnimator.getAnimatedValue();
            data.view.setLayoutParams(lp);
        }
    });

    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(final Animator animation) {
            finalizeDismiss();
        }
    });
    animator.start();
}
 
Example 2
Source File: SwipeDismissListViewTouchListener.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
protected void performDismiss(final PendingDismissData data) {
    // Animate the dismissed list item to zero-height and fire the
    // dismiss callback when all dismissed list item animations have
    // completed.

    final ViewGroup.LayoutParams lp = data.view.getLayoutParams();
    final int originalHeight = data.view.getHeight();

    ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mAnimationTime);

    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(final ValueAnimator valueAnimator) {
            lp.height = (Integer) valueAnimator.getAnimatedValue();
            data.view.setLayoutParams(lp);
        }
    });

    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(final Animator animation) {
            finalizeDismiss();
        }
    });
    animator.start();
}
 
Example 3
Source File: ViewPagerTabFragmentParentFragment.java    From Android-ObservableScrollView with Apache License 2.0 6 votes vote down vote up
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();
                View toolbarView = getActivity().findViewById(R.id.toolbar);
                ViewHelper.setTranslationY(mInterceptionLayout, translationY);
                ViewHelper.setTranslationY(toolbarView, translationY);
                if (translationY < 0) {
                    FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mInterceptionLayout.getLayoutParams();
                    lp.height = (int) (-translationY + getScreenHeight());
                    mInterceptionLayout.requestLayout();
                }
            }
        });
        animator.start();
    }
}
 
Example 4
Source File: ContextualUndoAdapter.java    From android-open-project-demo with Apache License 2.0 6 votes vote down vote up
private void performRemovalIfNecessary() {
    if (mCurrentRemovedId == -1) {
        return;
    }

    ContextualUndoView currentRemovedView = getCurrentRemovedView(mCurrentRemovedView, mCurrentRemovedId);
    if (currentRemovedView != null) {
        ValueAnimator animator = ValueAnimator.ofInt(currentRemovedView.getHeight(), 1).setDuration(ANIMATION_DURATION);

        RemoveViewAnimatorListenerAdapter listener = new RemoveViewAnimatorListenerAdapter(currentRemovedView, mCurrentRemovedId);
        RemoveViewAnimatorUpdateListener updateListener = new RemoveViewAnimatorUpdateListener(listener);

        animator.addListener(listener);
        animator.addUpdateListener(updateListener);
        animator.start();
    } else {
        // The hard way.
        deleteItemGivenId(mCurrentRemovedId);
    }
    clearCurrentRemovedView();
}
 
Example 5
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 6
Source File: CardFaceView.java    From CardView with Apache License 2.0 6 votes vote down vote up
private void onFlagChanged(final CardFlag oldFlag, final CardFlag newFlag) {
	int flagColor = CARD_BACKGROUND_COLOR_NOFLAG;
	if (newFlag != null) {
		flagColor = newFlag.getColor();
	}
	
	ValueAnimator fade = ObjectAnimator.ofInt(mCardPaint,
			"color", mCardPaint.getColor(), flagColor);
	fade.setDuration(500);
	fade.setEvaluator(new ArgbEvaluator());
	fade.addUpdateListener(new AnimatorUpdateListener() {
		@Override
		public void onAnimationUpdate(ValueAnimator value) {
			onFlagChangedUpdate(oldFlag, newFlag, value);
			invalidate();
		}
	});
	
	fade.start();
}
 
Example 7
Source File: ViewPagerTab2Activity.java    From Android-ObservableScrollView with Apache License 2.0 6 votes vote down vote up
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();
    }
}
 
Example 8
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 9
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 10
Source File: BGARefreshLayout.java    From AndroidStudyDemo with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 隐藏下拉刷新控件,带动画
 */
private void hiddenRefreshHeaderView() {
    ValueAnimator animator = ValueAnimator.ofInt(mWholeHeaderView.getPaddingTop(), mMinWholeHeaderViewPaddingTop);
    animator.setDuration(mRefreshViewHolder.getTopAnimDuration());
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            int paddingTop = (int) animation.getAnimatedValue();
            mWholeHeaderView.setPadding(0, paddingTop, 0, 0);
        }
    });
    animator.start();
}
 
Example 11
Source File: SwipeDismissTouchListener.java    From ListViewAnimations with Apache License 2.0 5 votes vote down vote up
/**
 * Animates the dismissed list item to zero-height and fires the dismiss callback when all dismissed list item animations have completed.
 *
 * @param view the dismissed {@link android.view.View}.
 */
protected void performDismiss(@NonNull final View view, final int position) {
    mDismissedViews.add(view);
    mDismissedPositions.add(position);

    ValueAnimator animator = ValueAnimator.ofInt(view.getHeight(), 1).setDuration(mDismissAnimationTime);
    animator.addUpdateListener(new DismissAnimatorUpdateListener(view));
    animator.addListener(new DismissAnimatorListener());
    animator.start();

    mActiveDismissCount++;
}
 
Example 12
Source File: ExpandableListItemAdapter.java    From android-open-project-demo with Apache License 2.0 5 votes vote down vote up
public static void animateExpanding(final View view, final AbsListView listView) {
    view.setVisibility(View.VISIBLE);

    View parent = (View) view.getParent();
    final int widthSpec = View.MeasureSpec.makeMeasureSpec(parent.getMeasuredWidth() - parent.getPaddingLeft() - parent.getPaddingRight(), View.MeasureSpec.AT_MOST);
    final int heightSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    view.measure(widthSpec, heightSpec);

    ValueAnimator animator = createHeightAnimator(view, 0, view.getMeasuredHeight());
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        final int listViewHeight = listView.getHeight();
        final int listViewBottomPadding = listView.getPaddingBottom();
        final View v = findDirectChild(view, listView);

        @Override
        public void onAnimationUpdate(final ValueAnimator valueAnimator) {
            final int bottom = v.getBottom();
            if (bottom > listViewHeight) {
                final int top = v.getTop();
                if (top > 0) {
                    listView.smoothScrollBy(Math.min(bottom - listViewHeight + listViewBottomPadding, top), 0);
                }
            }
        }
    });
    animator.start();
}
 
Example 13
Source File: SwipeListViewTouchListener.java    From browser with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Perform dismiss action
 *
 * @param dismissView     View
 * @param dismissPosition Position of list
 */
protected void performDismiss(final View dismissView, final int dismissPosition, boolean doPendingDismiss) {
    final ViewGroup.LayoutParams lp = dismissView.getLayoutParams();
    final int originalHeight = dismissView.getHeight();

    ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(animationTime);

    if (doPendingDismiss) {
        animator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                --dismissAnimationRefCount;
                if (dismissAnimationRefCount == 0) {
                    removePendingDismisses(originalHeight);
                }
            }
        });
    }

    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            lp.height = (Integer) valueAnimator.getAnimatedValue();
            dismissView.setLayoutParams(lp);
        }
    });

    pendingDismisses.add(new PendingDismissData(dismissPosition, dismissView));
    animator.start();
}
 
Example 14
Source File: BGARefreshLayout.java    From AndroidStudyDemo with GNU General Public License v2.0 5 votes vote down vote up
public void startChangeWholeHeaderViewPaddingTop(int distance) {
    ValueAnimator animator = ValueAnimator.ofInt(mWholeHeaderView.getPaddingTop(), mWholeHeaderView.getPaddingTop() - distance);
    animator.setDuration(mRefreshViewHolder.getTopAnimDuration());
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            int paddingTop = (int) animation.getAnimatedValue();
            mWholeHeaderView.setPadding(0, paddingTop, 0, 0);
        }
    });
    animator.start();
}
 
Example 15
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 16
Source File: DescriptionAnimation.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * When next item show in ViewPagerEx, let's make an animation to show the
 * description layout.
 * @param view
 */
@Override
public void onNextItemAppear(View view) {

    View descriptionLayout = view.findViewById(R.id.description_layout);
    if(descriptionLayout!=null){
        float layoutY = ViewHelper.getY(descriptionLayout);
        view.findViewById(R.id.description_layout).setVisibility(View.VISIBLE);
        ValueAnimator animator = ObjectAnimator.ofFloat(
                descriptionLayout,"y",layoutY + descriptionLayout.getHeight(),
                layoutY).setDuration(500);
        animator.start();
    }

}
 
Example 17
Source File: SwipeDismissTouchListener.java    From Pimp_my_Z1 with GNU General Public License v2.0 5 votes vote down vote up
private void performDismiss() {
	// Animate the dismissed view to zero-height and then fire the dismiss
	// callback.
	// This triggers layout on each animation frame; in the future we may
	// want to do something
	// smarter and more performant.

	final ViewGroup.LayoutParams lp = mView.getLayoutParams();
	final int originalHeight = mView.getHeight();

	ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1)
			.setDuration(mAnimationTime);

	animator.addListener(new AnimatorListenerAdapter() {
		@Override
		public void onAnimationEnd(Animator animation) {
			mCallback.onDismiss(mView, mToken);
			// Reset view presentation
			setAlpha(mView, 1f);
			ViewHelper.setTranslationX(mView, 0);
			// mView.setAlpha(1f);
			// mView.setTranslationX(0);
			lp.height = originalHeight;
			mView.setLayoutParams(lp);
		}
	});

	animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
		@Override
		public void onAnimationUpdate(ValueAnimator valueAnimator) {
			lp.height = (Integer) valueAnimator.getAnimatedValue();
			mView.setLayoutParams(lp);
		}
	});

	animator.start();
}
 
Example 18
Source File: ContextualUndoAdapter.java    From ALLGO with Apache License 2.0 5 votes vote down vote up
private void performRemovalIfNecessary() {
	if (mCurrentRemovedView != null && mCurrentRemovedView.getParent() != null) {
		ValueAnimator animator = ValueAnimator.ofInt(mCurrentRemovedView.getHeight(), 1).setDuration(ANIMATION_DURATION);
		animator.addListener(new RemoveViewAnimatorListenerAdapter(mCurrentRemovedView));
		animator.addUpdateListener(new RemoveViewAnimatorUpdateListener(mCurrentRemovedView));
		animator.start();
		mActiveAnimators.put(mCurrentRemovedView, animator);
		clearCurrentRemovedView();
	}
}
 
Example 19
Source File: DescriptionAnimation.java    From ImageSliderWithSwipes with Apache License 2.0 5 votes vote down vote up
/**
 * When next item show in ViewPagerEx, let's make an animation to show the
 * description layout.
 * @param view
 */
@Override
public void onNextItemAppear(View view) {

    View descriptionLayout = view.findViewById(R.id.description_layout);
    if(descriptionLayout!=null){
        float layoutY = ViewHelper.getY(descriptionLayout);
        view.findViewById(R.id.description_layout).setVisibility(View.VISIBLE);
        ValueAnimator animator = ObjectAnimator.ofFloat(
                descriptionLayout,"y",layoutY + descriptionLayout.getHeight(),
                layoutY).setDuration(500);
        animator.start();
    }

}
 
Example 20
Source File: ArrowRefreshHeader.java    From Xrv with Apache License 2.0 5 votes vote down vote up
private void smoothScrollTo(int destHeight) {
    ValueAnimator animator = ValueAnimator.ofInt(getVisibleHeight(), destHeight);
    animator.setDuration(300).start();
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            setVisibleHeight((int) animation.getAnimatedValue());
        }
    });
    animator.start();
}