Java Code Examples for com.nineoldandroids.animation.AnimatorSet#playTogether()

The following examples show how to use com.nineoldandroids.animation.AnimatorSet#playTogether() . 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: ResideMenu.java    From GifAssistant with Apache License 2.0 6 votes vote down vote up
/**
 * show the reside menu;
 */
public void openMenu(int direction){
    if (isInDisableDirection(direction))
        throw new IllegalArgumentException("You have set this direction disable, " +
                "but now you want to open menu in this direction.");
    setScaleDirection(direction);

    isOpened = true;
    AnimatorSet scaleDown_activity = buildScaleDownAnimation(viewActivity, 0.5f, 0.5f);
    AnimatorSet scaleDown_shadow = buildScaleDownAnimation(imageViewShadow,
            0.5f + shadowAdjustScaleX, 0.5f + shadowAdjustScaleY);
    AnimatorSet alpha_menu = buildMenuAnimation(scrollViewMenu, 1.0f);
    scaleDown_shadow.addListener(animationListener);
    scaleDown_activity.playTogether(scaleDown_shadow);
    scaleDown_activity.playTogether(alpha_menu);
    scaleDown_activity.start();
}
 
Example 2
Source File: SwipeUndoTouchListener.java    From ListViewAnimations with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 3
Source File: ViewAnimator.java    From ListViewAnimations with Apache License 2.0 6 votes vote down vote up
/**
 * Animates given View.
 *
 * @param view the View that should be animated.
 */
private void animateView(final int position, @NonNull final View view, @NonNull final Animator[] animators) {
    if (mAnimationStartMillis == -1) {
        mAnimationStartMillis = SystemClock.uptimeMillis();
    }

    ViewHelper.setAlpha(view, 0);

    AnimatorSet set = new AnimatorSet();
    set.playTogether(animators);
    set.setStartDelay(calculateAnimationDelay(position));
    set.setDuration(mAnimationDurationMillis);
    set.start();

    mAnimators.put(view.hashCode(), set);
}
 
Example 4
Source File: NineOldAndroidsActivity.java    From AndroidStudyDemo with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 打开菜单的动画
 * @param view 执行动画的view
 * @param index view在动画序列中的顺序
 * @param total 动画序列的个数
 * @param radius 动画半径
 */
private void doAnimateOpen(View view, int index, int total, int radius) {
    if (view.getVisibility() != View.VISIBLE) {
        view.setVisibility(View.VISIBLE);
    }
    double degree = Math.PI * index / ((total - 1) * 2);
    int translationX = (int) (radius * Math.cos(degree));
    int translationY = (int) (radius * Math.sin(degree));
    Logger.d(String.format("degree = %f, translationX = %d, translationY = %d", degree, translationX, translationY));
    AnimatorSet set = new AnimatorSet();
    // 包含平移、缩放和透明度动画
    set.playTogether(
            ObjectAnimator.ofFloat(view, "translationX", 0, translationX),
            ObjectAnimator.ofFloat(view, "translationY", 0, translationY),
            ObjectAnimator.ofFloat(view, "scaleX", 0f, 1f),
            ObjectAnimator.ofFloat(view, "scaleY", 0f, 1f),
            ObjectAnimator.ofFloat(view, "alpha", 0f, 1f)
    );
    // 动画周期为600ms
    set.setDuration(C.Int.MENU_DURATION * 2).start();
}
 
Example 5
Source File: ResideMenu.java    From AndroidResideMenu with MIT License 6 votes vote down vote up
/**
 * A helper method to build scale down animation;
 *
 * @param target
 * @param targetScaleX
 * @param targetScaleY
 * @return
 */
private AnimatorSet buildScaleDownAnimation(View target, float targetScaleX, float targetScaleY) {

    AnimatorSet scaleDown = new AnimatorSet();
    scaleDown.playTogether(
            ObjectAnimator.ofFloat(target, "scaleX", targetScaleX),
            ObjectAnimator.ofFloat(target, "scaleY", targetScaleY)
    );

    if (mUse3D) {
        int angle = scaleDirection == DIRECTION_LEFT ? -ROTATE_Y_ANGLE : ROTATE_Y_ANGLE;
        scaleDown.playTogether(ObjectAnimator.ofFloat(target, "rotationY", angle));
    }

    scaleDown.setInterpolator(AnimationUtils.loadInterpolator(activity,
            android.R.anim.decelerate_interpolator));
    scaleDown.setDuration(250);
    return scaleDown;
}
 
Example 6
Source File: SwitchAnimationUtil.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
private void runRotateAnimation(View view, long delay) {
	view.setAlpha(0);
	AnimatorSet set = new AnimatorSet();
	ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view,
			"rotation", 0f, 360f);
	ObjectAnimator objectAnimator2 = ObjectAnimator.ofFloat(view, "scaleX",
			0f, 1f);
	ObjectAnimator objectAnimator3 = ObjectAnimator.ofFloat(view, "scaleY",
			0f, 1f);
	ObjectAnimator objectAnimator4 = ObjectAnimator.ofFloat(view, "alpha",
			0f, 1f);

	objectAnimator2.setInterpolator(new AccelerateInterpolator(1.0f));
	objectAnimator3.setInterpolator(new AccelerateInterpolator(1.0f));

	set.setDuration(mDuration);
	set.playTogether(objectAnimator, objectAnimator2, objectAnimator3,
			objectAnimator4);
	set.setStartDelay(delay);
	set.start();
}
 
Example 7
Source File: AnimationAdapter.java    From ALLGO with Apache License 2.0 6 votes vote down vote up
private void animateView(int position, ViewGroup parent, View view) {
	if (mAnimationStartMillis == -1) {
		mAnimationStartMillis = System.currentTimeMillis();
	}

	ViewHelper.setAlpha(view, 0);

	Animator[] childAnimators;
	if (mDecoratedBaseAdapter instanceof AnimationAdapter) {
		childAnimators = ((AnimationAdapter) mDecoratedBaseAdapter).getAnimators(parent, view);
	} else {
		childAnimators = new Animator[0];
	}
	Animator[] animators = getAnimators(parent, view);
	Animator alphaAnimator = ObjectAnimator.ofFloat(view, "alpha", 0, 1);

	AnimatorSet set = new AnimatorSet();
	set.playTogether(concatAnimators(childAnimators, animators, alphaAnimator));
	set.setStartDelay(calculateAnimationDelay());
	set.setDuration(getAnimationDurationMillis());
	set.start();

	mAnimators.put(view.hashCode(), set);
}
 
Example 8
Source File: ResideMenu.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * a helper method to build scale up animation;
 *
 * @param target
 * @param targetScaleX
 * @param targetScaleY
 * @return
 */
private AnimatorSet buildScaleUpAnimation(View target,float targetScaleX,float targetScaleY){

    AnimatorSet scaleUp = new AnimatorSet();
    scaleUp.playTogether(
            ObjectAnimator.ofFloat(target, "scaleX", targetScaleX),
            ObjectAnimator.ofFloat(target, "scaleY", targetScaleY)
    );

    scaleUp.setDuration(250);
    return scaleUp;
}
 
Example 9
Source File: ResideMenu.java    From iSCAU-Android with GNU General Public License v3.0 5 votes vote down vote up
private AnimatorSet buildMenuAnimation(View target, float alpha){

        AnimatorSet alphaAnimation = new AnimatorSet();
        alphaAnimation.playTogether(
                ObjectAnimator.ofFloat(target, "alpha", alpha)
        );

        alphaAnimation.setDuration(250);
        return alphaAnimation;
    }
 
Example 10
Source File: SwipeTouchListener.java    From ListViewAnimations with Apache License 2.0 5 votes vote down vote up
/**
 * Animates the pending {@link android.view.View} back to its original position.
 */
private void restoreCurrentViewTranslation() {
    if (mCurrentView == null) {
        return;
    }

    ObjectAnimator xAnimator = ObjectAnimator.ofFloat(mSwipingView, TRANSLATION_X, 0);
    ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(mSwipingView, ALPHA, 1);

    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(xAnimator, alphaAnimator);
    animatorSet.setDuration(mAnimationTime);
    animatorSet.addListener(new RestoreAnimatorListener(mCurrentView, mCurrentPosition));
    animatorSet.start();
}
 
Example 11
Source File: ResideMenu.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * a helper method to build scale down animation;
 * 
 * @param target
 * @param targetScaleX
 * @param targetScaleY
 * @return
 */
private AnimatorSet buildScaleDownAnimation(View target,
		float targetScaleX, float targetScaleY) {
	AnimatorSet scaleDown = new AnimatorSet();
	scaleDown.playTogether(
			ObjectAnimator.ofFloat(target, "scaleX", targetScaleX),
			ObjectAnimator.ofFloat(target, "scaleY", targetScaleY));

	scaleDown.setInterpolator(AnimationUtils.loadInterpolator(activity,
			android.R.anim.decelerate_interpolator));
	scaleDown.setDuration(130); // 250
	return scaleDown;
}
 
Example 12
Source File: ResideMenu.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * close the reslide menu;
 */
public void closeMenu(){

    isOpened = false;
    AnimatorSet scaleUp_activity = buildScaleUpAnimation(viewActivity, 1.0f, 1.0f);
    AnimatorSet scaleUp_shadow = buildScaleUpAnimation(imageViewShadow, 1.0f, 1.0f);
    AnimatorSet alpha_menu = buildMenuAnimation(scrollViewMenu, 0.0f);
    scaleUp_activity.addListener(animationListener);
    scaleUp_activity.playTogether(scaleUp_shadow);
    scaleUp_activity.playTogether(alpha_menu);
    scaleUp_activity.start();
}
 
Example 13
Source File: SwitchAnimationUtil.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private void runHorizonRightAnimation(View view, long delay) {
	view.setAlpha(0);
	ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view,
			"translationX", ViewUtils.getScreenWidth(), 0);
	objectAnimator.setInterpolator(new LinearInterpolator());
	ObjectAnimator objectAnimatorAlpha = ObjectAnimator.ofFloat(view,
			"alpha", 0f, 1f);
	AnimatorSet set = new AnimatorSet();
	set.setStartDelay(delay);
	set.setDuration(mDuration);
	set.playTogether(objectAnimator, objectAnimatorAlpha);
	set.start();
}
 
Example 14
Source File: StickyListAdapter.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
private void addAnimation(View view) {
    float[] vaules = new float[] {0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.2f, 1.3f, 1.25f, 1.2f, 1.15f, 1.1f, 1.0f};
    AnimatorSet set = new AnimatorSet();
    set.playTogether(ObjectAnimator.ofFloat(view, "scaleX", vaules),
            ObjectAnimator.ofFloat(view, "scaleY", vaules));
    set.setDuration(150);
    set.start();
}
 
Example 15
Source File: ResideMenu.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * a helper method to build scale down animation;
 *
 * @param target
 * @param targetScaleX
 * @param targetScaleY
 * @return
 */
private AnimatorSet buildScaleDownAnimation(View target,float targetScaleX,float targetScaleY){

    AnimatorSet scaleDown = new AnimatorSet();
    scaleDown.playTogether(
            ObjectAnimator.ofFloat(target, "scaleX", targetScaleX),
            ObjectAnimator.ofFloat(target, "scaleY", targetScaleY)
    );

    scaleDown.setInterpolator(AnimationUtils.loadInterpolator(activity,
            android.R.anim.decelerate_interpolator));
    scaleDown.setDuration(250);
    return scaleDown;
}
 
Example 16
Source File: SimpleAnimation.java    From Android-PullToNextLayout with Apache License 2.0 5 votes vote down vote up
public Animator getDeleteItemShowAnimation(View view) {
    ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 0.7f, 1);
    ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 0.7f, 1);
    AnimatorSet set = new AnimatorSet();
    set.setInterpolator(new DecelerateInterpolator());
    scaleY.setDuration(ANIMATION_DURATION);
    scaleX.setDuration(ANIMATION_DURATION);
    set.setDuration(ANIMATION_DURATION);
    set.playTogether(scaleY, scaleX);
    return set;
}
 
Example 17
Source File: CellViewHolder.java    From MaterialLeanBack with Apache License 2.0 5 votes vote down vote up
public void enlarge(boolean withAnimation) {
    if (!enlarged && settings.animateCards) {

        if (currentAnimator != null) {
            currentAnimator.cancel();
            currentAnimator = null;
        }

        int duration = withAnimation ? 300 : 0;

        adapter.itemPosition = getAdapterPosition();

        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.setDuration(duration);

        List<Animator> animatorList = new ArrayList<>();
        animatorList.add(ObjectAnimator.ofFloat(cardView, "scaleX", scaleEnlarged));
        animatorList.add(ObjectAnimator.ofFloat(cardView, "scaleY", scaleEnlarged));

        if (settings.overlapCards) {
            //animatorList.add(ObjectAnimator.ofFloat(cardView, "translationX", translationX));
            animatorSet.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationStart(Animator animation) {
                    cardView.setCardElevation(settings.elevationEnlarged);
                    currentAnimator = null;
                }
            });
        }

        animatorSet.playTogether(animatorList);
        currentAnimator = animatorSet;
        animatorSet.start();

        enlarged = true;
    }
}
 
Example 18
Source File: ResideMenu.java    From GifAssistant with Apache License 2.0 5 votes vote down vote up
private AnimatorSet buildMenuAnimation(View target, float alpha){

        AnimatorSet alphaAnimation = new AnimatorSet();
        alphaAnimation.playTogether(
                ObjectAnimator.ofFloat(target, "alpha", alpha)
        );

        alphaAnimation.setDuration(250);
        return alphaAnimation;
    }
 
Example 19
Source File: DragGridView.java    From DragGridView with Apache License 2.0 5 votes vote down vote up
private Animator createTranslationAnimations(View view, float startX, float endX, float startY, float endY)
{
    ObjectAnimator animX = ObjectAnimator.ofFloat(view, "translationX", startX, endX);
    ObjectAnimator animY = ObjectAnimator.ofFloat(view, "translationY", startY, endY);
    AnimatorSet animSetXY = new AnimatorSet();
    animSetXY.playTogether(animX, animY);
    return animSetXY;
}
 
Example 20
Source File: AllMembersAdapter.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 给CheckBox加点击动画,利用开源库nineoldandroids设置动画
 */
private void addAnimation(View view) {
    float[] vaules = new float[]{0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.2f, 1.3f, 1.25f, 1.2f, 1.15f, 1.1f, 1.0f};
    AnimatorSet set = new AnimatorSet();
    set.playTogether(ObjectAnimator.ofFloat(view, "scaleX", vaules),
            ObjectAnimator.ofFloat(view, "scaleY", vaules));
    set.setDuration(150);
    set.start();
}