android.animation.AnimatorSet Java Examples

The following examples show how to use android.animation.AnimatorSet. 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 Project: welcome-coordinator   Author: txusballesteros   File: RocketAvatarsAnimator.java    License: Apache License 2.0 6 votes vote down vote up
private void initializeAnimator() {
    final View rocketFlame = rootView.findViewById(R.id.rocket_flame);
    final View avatar1 = rootView.findViewById(R.id.avatar1);
    final View avatar2 = rootView.findViewById(R.id.avatar2);
    final View avatar3 = rootView.findViewById(R.id.avatar3);
    final View avatar4 = rootView.findViewById(R.id.avatar4);
    Animator avatar1Animator = getAnimator(avatar1);
    Animator avatar2Animator = getAnimator(avatar2);
    Animator avatar3Animator = getAnimator(avatar3);
    Animator avatar4Animator = getAnimator(avatar4);
    rocketFlameAnimator = getFlameAnimator(rocketFlame);
    animator = new AnimatorSet();
    animator.setStartDelay(500);
    animator.play(avatar3Animator).after(avatar4Animator);
    animator.play(avatar2Animator).after(avatar3Animator);
    animator.play(avatar1Animator).after(avatar2Animator);
}
 
Example #2
Source Project: TelePlus-Android   Author: TelePlusDev   File: ChatActivityEnterView.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void hideRecordedAudioPanel()
{
    audioToSendPath = null;
    audioToSend = null;
    audioToSendMessageObject = null;
    videoToSendMessageObject = null;
    videoTimelineView.destroy();
    AnimatorSet AnimatorSet = new AnimatorSet();
    AnimatorSet.playTogether(
            ObjectAnimator.ofFloat(recordedAudioPanel, "alpha", 0.0f)
    );
    AnimatorSet.setDuration(200);
    AnimatorSet.addListener(new AnimatorListenerAdapter()
    {
        @Override
        public void onAnimationEnd(Animator animation)
        {
            recordedAudioPanel.setVisibility(GONE);

        }
    });
    AnimatorSet.start();
}
 
Example #3
Source Project: TelePlus-Android   Author: TelePlusDev   File: DialogsActivity.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void hideFloatingButton(boolean hide)
{
    if (floatingHidden == hide)
    {
        return;
    }
    floatingHidden = hide;
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(ObjectAnimator.ofFloat(floatingButton, "translationY", floatingHidden ?
                    AndroidUtilities.dp(!FeaturedSettings.tabSettings.hideTabs && FeaturedSettings.tabSettings.tabsToBottom ? 150 : 100) : 0),
            ObjectAnimator.ofFloat(unreadFloatingButtonContainer, "translationY", floatingHidden ? AndroidUtilities.dp(74) : 0));
    animatorSet.setDuration(300);
    animatorSet.setInterpolator(floatingInterpolator);
    floatingButton.setClickable(!hide);
    animatorSet.start();
}
 
Example #4
Source Project: XMiTools   Author: tianma8023   File: MiuiKeyguardVerticalClockHook.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void hookClearAnim() {
    findAndHookMethod(mMiuiKeyguardVerticalClockCls,
            "clearAnim",
            new MethodHookWrapper() {
                @Override
                protected void after(MethodHookParam param) {
                    Object keyguardClock = param.thisObject;
                    AnimatorSet mHorizontalToVerticalAnim2 = (AnimatorSet) getAdditionalInstanceField(keyguardClock, M_HORIZONTAL_TO_VERTICAL_ANIM_2);
                    if (mHorizontalToVerticalAnim2 != null) {
                        mHorizontalToVerticalAnim2.cancel();
                    }

                    AnimatorSet mVerticalToHorizontalAnim2 = (AnimatorSet) getAdditionalInstanceField(keyguardClock, M_VERTICAL_TO_HORIZONTAL_ANIM_2);
                    if (mVerticalToHorizontalAnim2 != null) {
                        mVerticalToHorizontalAnim2.cancel();
                    }

                    TextView mVerticalSec = (TextView) getAdditionalInstanceField(keyguardClock, M_VERTICAL_SEC);
                    if (mVerticalSec != null) {
                        mVerticalSec.clearAnimation();
                    }
                }
            });
}
 
Example #5
Source Project: TelePlus-Android   Author: TelePlusDev   File: ChannelAdminLogActivity.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void hideFloatingDateView(boolean animated) {
    if (floatingDateView.getTag() != null && !currentFloatingDateOnScreen && (!scrollingFloatingDate || currentFloatingTopIsNotMessage)) {
        floatingDateView.setTag(null);
        if (animated) {
            floatingDateAnimation = new AnimatorSet();
            floatingDateAnimation.setDuration(150);
            floatingDateAnimation.playTogether(ObjectAnimator.ofFloat(floatingDateView, "alpha", 0.0f));
            floatingDateAnimation.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    if (animation.equals(floatingDateAnimation)) {
                        floatingDateAnimation = null;
                    }
                }
            });
            floatingDateAnimation.setStartDelay(500);
            floatingDateAnimation.start();
        } else {
            if (floatingDateAnimation != null) {
                floatingDateAnimation.cancel();
                floatingDateAnimation = null;
            }
            floatingDateView.setAlpha(0.0f);
        }
    }
}
 
Example #6
Source Project: FlyRefresh   Author: race604   File: SampleItemAnimator.java    License: MIT License 6 votes vote down vote up
@Override
protected void animateAddImpl(final RecyclerView.ViewHolder holder) {
    View target = holder.itemView;
    View icon = target.findViewById(R.id.icon);
    Animator swing = ObjectAnimator.ofFloat(icon, "rotationX", 45, 0);
    swing.setInterpolator(new OvershootInterpolator(5));

    View right = holder.itemView.findViewById(R.id.right);
    Animator rotateIn = ObjectAnimator.ofFloat(right, "rotationY", 90, 0);
    rotateIn.setInterpolator(new DecelerateInterpolator());

    AnimatorSet animator = new AnimatorSet();
    animator.setDuration(getAddDuration());
    animator.playTogether(swing, rotateIn);

    animator.start();
}
 
Example #7
Source Project: MediaPickerInstagram   Author: luoyiqi   File: CapturePhotoFragment.java    License: Apache License 2.0 6 votes vote down vote up
private void animateShutter() {
    mShutter.setVisibility(View.VISIBLE);
    mShutter.setAlpha(0.f);

    ObjectAnimator alphaInAnim = ObjectAnimator.ofFloat(mShutter, "alpha", 0f, 0.8f);
    alphaInAnim.setDuration(100);
    alphaInAnim.setStartDelay(100);
    alphaInAnim.setInterpolator(ACCELERATE_INTERPOLATOR);

    ObjectAnimator alphaOutAnim = ObjectAnimator.ofFloat(mShutter, "alpha", 0.8f, 0f);
    alphaOutAnim.setDuration(200);
    alphaOutAnim.setInterpolator(DECELERATE_INTERPOLATOR);

    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playSequentially(alphaInAnim, alphaOutAnim);
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mShutter.setVisibility(View.GONE);
        }
    });
    animatorSet.start();
}
 
Example #8
Source Project: ColorPhun   Author: prakhar1989   File: MainGameActivity.java    License: Apache License 2.0 6 votes vote down vote up
protected void setupProgressView() {
    timerProgress = (ProgressBar) findViewById(R.id.progress_bar);
    pointsTextView = (TextView) findViewById(R.id.points_value);
    levelTextView = (TextView) findViewById(R.id.level_value);
    TextView pointsLabel = (TextView) findViewById(R.id.points_label);
    TextView levelsLabel = (TextView) findViewById(R.id.level_label);

    // setting up fonts
    Typeface avenir_black = Typeface.createFromAsset(getAssets(), "fonts/avenir_black.ttf");
    Typeface avenir_book = Typeface.createFromAsset(getAssets(), "fonts/avenir_book.ttf");
    pointsTextView.setTypeface(avenir_black);
    levelTextView.setTypeface(avenir_black);
    pointsLabel.setTypeface(avenir_book);
    levelsLabel.setTypeface(avenir_book);

    // setting up animations
    pointAnim = (AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.points_animations);
    pointAnim.setTarget(pointsTextView);
    levelAnim = (AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.level_animations);
    levelAnim.setTarget(levelTextView);
}
 
Example #9
Source Project: Telegram-FOSS   Author: Telegram-FOSS-Team   File: ChannelAdminLogActivity.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void hideFloatingDateView(boolean animated) {
    if (floatingDateView.getTag() != null && !currentFloatingDateOnScreen && (!scrollingFloatingDate || currentFloatingTopIsNotMessage)) {
        floatingDateView.setTag(null);
        if (animated) {
            floatingDateAnimation = new AnimatorSet();
            floatingDateAnimation.setDuration(150);
            floatingDateAnimation.playTogether(ObjectAnimator.ofFloat(floatingDateView, "alpha", 0.0f));
            floatingDateAnimation.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    if (animation.equals(floatingDateAnimation)) {
                        floatingDateAnimation = null;
                    }
                }
            });
            floatingDateAnimation.setStartDelay(500);
            floatingDateAnimation.start();
        } else {
            if (floatingDateAnimation != null) {
                floatingDateAnimation.cancel();
                floatingDateAnimation = null;
            }
            floatingDateView.setAlpha(0.0f);
        }
    }
}
 
Example #10
Source Project: rnd-android-wear-tesla   Author: eleks   File: ActionTeslaFragment.java    License: MIT License 6 votes vote down vote up
private void performActionAnimation(View view) {
    ValueAnimator startAnim = ValueAnimator.ofInt(mNormalImageSize, getSizeFromCoef(START_ANIMATION_OUT_SCALE_END));
    startAnim.addUpdateListener(new ScaleAnimateListener(view));
    startAnim.setDuration(START_ANIMATION_TIME);

    AnimatorSet middleAnim = new AnimatorSet();
    ValueAnimator middleOutScale = ValueAnimator.ofInt(getSizeFromCoef(MIDDLE_ANIMATION_OUT_SCALE_START), getSizeFromCoef(MIDDLE_ANIMATION_OUT_SCALE_END));
    middleOutScale.addUpdateListener(new ScaleAnimateListener(view));
    ValueAnimator middleInAlpha = ValueAnimator.ofFloat(MIDDLE_ANIMATION_IN_ALPHA_START, MIDDLE_ANIMATION_IN_ALPHA_END);
    middleInAlpha.addUpdateListener(new AlphaAnimateListener(view));
    middleAnim.playTogether(middleOutScale, middleInAlpha);
    middleAnim.setDuration(MIDDLE_ANIMATION_TIME);

    AnimatorSet endAnim = new AnimatorSet();
    ValueAnimator endInScale = ValueAnimator.ofInt(getSizeFromCoef(END_ANIMATION_IN_SCALE_START), getSizeFromCoef(END_ANIMATION_IN_SCALE_END));
    endInScale.addUpdateListener(new ScaleAnimateListener(view));
    ValueAnimator endInAlpha = ValueAnimator.ofFloat(END_ANIMATION_IN_ALPHA_START, END_ANIMATION_IN_ALPHA_END);
    endInAlpha.addUpdateListener(new AlphaAnimateListener(view));
    endAnim.playTogether(endInScale, endInAlpha);
    endAnim.setDuration(END_ANIMATION_TIME);

    AnimatorSet mainAnim = new AnimatorSet();
    mainAnim.playSequentially(startAnim, middleAnim, endAnim);
    mainAnim.setInterpolator(new LinearInterpolator());
    mainAnim.start();
}
 
Example #11
Source Project: Study_Android_Demo   Author: RealMoMo   File: MainActivity.java    License: Apache License 2.0 6 votes vote down vote up
public void setObj(View view) {
	// ��ȡ��Ļ�Ŀ��
	DisplayMetrics metri = getResources().getDisplayMetrics();
	// ����������Ϊ��λ
	int width = metri.widthPixels;
	// ���ߣ�������Ϊ��λ
	int height = metri.heightPixels;
	// 2.����x,y��������Զ���
	ObjectAnimator objTranY = ObjectAnimator.ofFloat(ib, "TranslationY", 0,
			height - 2 * ib.getHeight());
	ObjectAnimator objTranX = ObjectAnimator.ofFloat(ib, "TranslationX", 0,
			width - ib.getWidth());
	// 3.����AnimatorSet
	AnimatorSet set = new AnimatorSet();
	
	set.setDuration(3000);
	// 4.ͨ��AnimatorSet.play��Ӳ����ò���ģʽ
	set.playTogether(objTranX, objTranY);
	// 5.����
	set.start();

}
 
Example #12
Source Project: TurboLauncher   Author: Phonemetra   File: CellLayout.java    License: Apache License 2.0 6 votes vote down vote up
private void completeAnimationImmediately() {
    if (a != null) {
        a.cancel();
    }

    AnimatorSet s = LauncherAnimUtils.createAnimatorSet();
    a = s;
    s.playTogether(
        LauncherAnimUtils.ofFloat(child, "scaleX", getChildrenScale()),
        LauncherAnimUtils.ofFloat(child, "scaleY", getChildrenScale()),
        LauncherAnimUtils.ofFloat(child, "translationX", 0f),
        LauncherAnimUtils.ofFloat(child, "translationY", 0f)
    );
    s.setDuration(REORDER_ANIMATION_DURATION);
    s.setInterpolator(new android.view.animation.DecelerateInterpolator(1.5f));
    s.start();
}
 
Example #13
Source Project: AndroidChromium   Author: JackyAndroid   File: SnackbarView.java    License: Apache License 2.0 6 votes vote down vote up
void dismiss() {
    // Disable action button during animation.
    mActionButtonView.setEnabled(false);
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.setDuration(mAnimationDuration);
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mParent.removeOnLayoutChangeListener(mLayoutListener);
            mParent.removeView(mView);
        }
    });
    Animator moveDown = ObjectAnimator.ofFloat(mView, View.TRANSLATION_Y,
            mView.getHeight() + getLayoutParams().bottomMargin);
    moveDown.setInterpolator(new DecelerateInterpolator());
    Animator fadeOut = ObjectAnimator.ofFloat(mView, View.ALPHA, 0f);
    fadeOut.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE);

    animatorSet.playTogether(fadeOut, moveDown);
    startAnimatorOnSurfaceView(animatorSet);
}
 
Example #14
Source Project: AndroidAll   Author: chiclaim   File: AnimatorSetFragment.java    License: Apache License 2.0 6 votes vote down vote up
private void startByBuilder() {
    ObjectAnimator objectAnimatorA = ObjectAnimator.ofFloat(viewTargetA,
            "translationY", 0, 300, 0);
    ObjectAnimator colorAnimatorA = ObjectAnimator.ofInt(viewTargetA,
            "backgroundColor", 0xffffffff, 0xffff00ff, 0xffffff00);

    ObjectAnimator objectAnimatorB = ObjectAnimator.ofFloat(viewTargetB,
            "translationY", 0, 300, 0);

    //===============================================================
    //先同时执行objectAnimator1和colorAnimator,完毕后再执行objectAnimator2
    //builder方法解释:
    //with(animator) 和前面的动画一起执行
    //before(animator) 前面的动画在参数animator动画执行之前执行
    //after(animator) 前面的动画在参数animator动画执行完之执行
    //如何理解 :  方法名(参数),从右往左读. 重点是参数,前面的动画到底是在参数之前还是之后执行 通过方法名就知道了.
    //===============================================================

    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.play(objectAnimatorA)
            .with(colorAnimatorA)
            .before(objectAnimatorB);

    animatorSet.setDuration(1000);
    animatorSet.start();
}
 
Example #15
Source Project: AndroidAll   Author: chiclaim   File: AnimatorSetFragment.java    License: Apache License 2.0 6 votes vote down vote up
private void doAnimateOpen(View view, int index, int total, int radius) {
    if (view.getVisibility() != View.VISIBLE) {
        view.setVisibility(View.VISIBLE);
    }
    double degree = Math.toRadians(90) / (total - 1) * index;
    int translationX = -(int) (radius * Math.sin(degree));
    int translationY = -(int) (radius * Math.cos(degree));

    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, 1));
    //动画周期为500ms
    set.setDuration(300).start();
}
 
Example #16
Source Project: PowerfulRecyclerView   Author: zjutkz   File: ZoomInAnimator.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected AnimatorSet generateRemoveAnimator(RecyclerView.ViewHolder holder) {
    View target = holder.itemView;

    AnimatorSet animator = new AnimatorSet();

    animator.playTogether(
            ObjectAnimator.ofFloat(target, "scaleX", 1.0f, 0.0f),
            ObjectAnimator.ofFloat(target, "scaleY", 1.0f, 0.0f)
    );

    animator.setTarget(target);
    animator.setDuration(getRemoveDuration());

    return animator;
}
 
Example #17
Source Project: delion   Author: derry   File: AccessibilityTabModelListItem.java    License: Apache License 2.0 6 votes vote down vote up
private void runBlinkOutAnimation() {
    cancelRunningAnimation();
    mSwipedAway = 0;

    ObjectAnimator stretchX = ObjectAnimator.ofFloat(this, View.SCALE_X, 1.2f);
    ObjectAnimator shrinkY = ObjectAnimator.ofFloat(this, View.SCALE_Y, 0.f);
    ObjectAnimator fadeOut = ObjectAnimator.ofFloat(this, View.ALPHA, 0.f);

    AnimatorSet set = new AnimatorSet();
    set.playTogether(fadeOut, shrinkY, stretchX);
    set.addListener(mCloseAnimatorListener);
    set.setDuration(mCloseAnimationDurationMs);
    set.start();

    mActiveAnimation = set;
}
 
Example #18
Source Project: Flubber   Author: Appolica   File: MainActivity.java    License: Apache License 2.0 6 votes vote down vote up
private AnimatorSet getHideWithReveal(final View toHide) {
    final AnimatorSet animatorSet = new AnimatorSet();

    binding.revealView.setVisibility(View.VISIBLE);

    final Animator revealAnimation =
            Flubber.with()
                    .animation(RevealProvider.create(binding.floatingActionButton, binding.revealView, false))
                    .duration(DURATION_REVEAL)
                    .createFor(toHide);

    final Animator fadeOut =
            Flubber.with()
                    .animation(Flubber.AnimationPreset.FADE_IN)
                    .interpolator(Flubber.Curve.BZR_EASE_OUT)
                    .duration(DURATION_FADE)
                    .listener(SimpleAnimatorListener.forEnd(animation -> toHide.setVisibility(View.INVISIBLE)))
                    .createFor(binding.revealView);

    animatorSet.play(revealAnimation).after(fadeOut);

    return animatorSet;
}
 
Example #19
Source Project: UltimateAndroid   Author: cymcsg   File: DefaultLayoutAnimator.java    License: Apache License 2.0 6 votes vote down vote up
/**
 *
 */
protected AnimatorSet getItemsAddedAnimation(List<FreeFlowItem> added) {
    AnimatorSet appearingSet = new AnimatorSet();
    ArrayList<Animator> fadeIns = new ArrayList<Animator>();
    for (FreeFlowItem proxy : added) {
        proxy.view.setAlpha(0);
        fadeIns.add(ObjectAnimator.ofFloat(proxy.view, "alpha", 1));
    }

    if (animateIndividualCellsSequentially)
        appearingSet.playSequentially(fadeIns);
    else
        appearingSet.playTogether(fadeIns);

    appearingSet.setStartDelay(newCellsAdditionAnimationStartDelay);
    appearingSet.setDuration(newCellsAdditionAnimationDurationPerCell);
    return appearingSet;
}
 
Example #20
Source Project: welcome-coordinator   Author: txusballesteros   File: InSyncAnimator.java    License: Apache License 2.0 6 votes vote down vote up
private void initializeAnimator() {
    final View avatarView = rootView.findViewById(R.id.avatar5);
    final View arrowChartMaskView = rootView.findViewById(R.id.arrow_chart_mask);
    final ObjectAnimator scaleXAnimator = ObjectAnimator
            .ofFloat(avatarView, View.SCALE_X, 0f, 1f);
    scaleXAnimator.setDuration(300);
    scaleXAnimator.setInterpolator(new OvershootInterpolator());
    final ObjectAnimator scaleYAnimator = ObjectAnimator
            .ofFloat(avatarView, View.SCALE_Y, 0f, 1f);
    scaleYAnimator.setDuration(300);
    scaleYAnimator.setInterpolator(new OvershootInterpolator());
    final ObjectAnimator maskScaleXAnimator = ObjectAnimator
            .ofFloat(arrowChartMaskView, View.SCALE_X, 1f, 0f);
    maskScaleXAnimator.setDuration(500);
    maskScaleXAnimator.setInterpolator(new LinearInterpolator());
    animator = new AnimatorSet();
    animator.play(scaleXAnimator).with(scaleYAnimator).before(maskScaleXAnimator);
}
 
Example #21
Source Project: KrGallery   Author: chengzichen   File: ShutterButton.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void setHighlighted(boolean value) {
    AnimatorSet animatorSet = new AnimatorSet();
    if (value) {
        animatorSet.playTogether(
                ObjectAnimator.ofFloat(this, "scaleX", 1.06f),
                ObjectAnimator.ofFloat(this, "scaleY", 1.06f));
    } else {
        animatorSet.playTogether(
                ObjectAnimator.ofFloat(this, "scaleX", 1.0f),
                ObjectAnimator.ofFloat(this, "scaleY", 1.0f));
        animatorSet.setStartDelay(40);
    }
    animatorSet.setDuration(120);
    animatorSet.setInterpolator(interpolator);
    animatorSet.start();
}
 
Example #22
Source Project: AlbumCameraRecorder   Author: zhongjhATC   File: OperationLayout.java    License: MIT License 6 votes vote down vote up
/**
 * 拍点击长按结果后的动画 - 多图片
 */
public void startOperaeBtnAnimatorMulti() {
    // 如果本身隐藏的,就显示出来
    if (mViewHolder.btnConfirm.getVisibility() == View.GONE) {
        // 显示提交按钮
        mViewHolder.btnConfirm.setVisibility(VISIBLE);
        // 动画未结束前不能让它们点击
        mViewHolder.btnConfirm.setClickable(false);

        // 显示动画
        ObjectAnimator animatorConfirm = ObjectAnimator.ofFloat(mViewHolder.btnConfirm, "translationX", -mLayoutWidth / 4, 0);
        AnimatorSet set = new AnimatorSet();
        set.playTogether(animatorConfirm);
        set.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                // 动画结束使得按钮可点击
                mViewHolder.btnConfirm.setClickable(true);
            }
        });
        set.setDuration(200);
        set.start();
    }
}
 
Example #23
Source Project: flowless   Author: Zhuinden   File: FlowAnimation.java    License: Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public Animator createAnimation(@NonNull View previousView, @NonNull View newView, Direction direction) {
    if(direction == Direction.REPLACE) {
        return null;
    }
    boolean backward = direction == Direction.BACKWARD;
    int fromTranslation = backward ? previousView.getWidth() : -previousView.getWidth();
    int toTranslation = backward ? -newView.getWidth() : newView.getWidth();

    AnimatorSet set = new AnimatorSet();

    set.play(ObjectAnimator.ofFloat(previousView, View.TRANSLATION_X, fromTranslation));
    set.play(ObjectAnimator.ofFloat(newView, View.TRANSLATION_X, toTranslation, 0));

    return set;
}
 
Example #24
Source Project: UltimateAndroid   Author: cymcsg   File: FadeInAnimation.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public AnimatorSet getAnimatorSet() {
	view.setAlpha(0f);
	view.setVisibility(View.VISIBLE);

	AnimatorSet fadeSet = new AnimatorSet();
	fadeSet.play(ObjectAnimator.ofFloat(view, View.ALPHA, 1f));
	fadeSet.setInterpolator(interpolator);
	fadeSet.setDuration(duration);
	fadeSet.addListener(new AnimatorListenerAdapter() {

		@Override
		public void onAnimationEnd(Animator animation) {
			if (getListener() != null) {
				getListener().onAnimationEnd(FadeInAnimation.this);
			}
		}
	});
	return fadeSet;
}
 
Example #25
Source Project: NIM_Android_UIKit   Author: netease-im   File: CaptureActivity.java    License: MIT License 5 votes vote down vote up
public void stopButtonAnimation() {
    AnimatorSet animatorSet = new AnimatorSet();//组合动画
    ObjectAnimator scaleX = ObjectAnimator.ofFloat(capturebg, "scaleX", 1.4f, 1f);
    ObjectAnimator scaleY = ObjectAnimator.ofFloat(capturebg, "scaleY", 1.4f, 1f);
    //        mProgressView.setVisibility(View.INVISIBLE);
    capturebg.setVisibility(View.VISIBLE);
    animatorSet.setDuration(100);
    animatorSet.setInterpolator(new LinearInterpolator());
    animatorSet.play(scaleX).with(scaleY);//两个动画同时开始
    animatorSet.start();
    cameraTip.setVisibility(View.VISIBLE);
}
 
Example #26
Source Project: Telegram-FOSS   Author: Telegram-FOSS-Team   File: FloatingToolbar.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static AnimatorSet createExitAnimation(View view, int startDelay, Animator.AnimatorListener listener) {
    AnimatorSet animation = new AnimatorSet();
    animation.playTogether(ObjectAnimator.ofFloat(view, View.ALPHA, 1, 0).setDuration(100));
    animation.setStartDelay(startDelay);
    animation.addListener(listener);
    return animation;
}
 
Example #27
Source Project: AndroidAnimationsActions   Author: dtx12   File: RepeatAction.java    License: MIT License 5 votes vote down vote up
private long countDuration(Animator animator) {
    long duration = 0;
    if (animator instanceof AnimatorSet) {
        for (Animator child : ((AnimatorSet) animator).getChildAnimations()) {
            duration += countDuration(child);
        }
    } else if (animator instanceof RepeatAction) {
        duration += countDuration(((RepeatAction) animator).animator);
    } else {
        duration += animator.getDuration();
    }
    return Math.max(duration, 0);
}
 
Example #28
Source Project: terminal-seekbar   Author: alshell7   File: TerminalBackDrawable.java    License: Apache License 2.0 5 votes vote down vote up
public TerminalBackDrawable(int color, float radius) {
    this.color = color;
    this.radius = radius;
    this.blinkScale = 0f;
    this.alpha = 255;

    terminalPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    animatorSet = new AnimatorSet();

}
 
Example #29
Source Project: Trebuchet   Author: talentlo   File: WorkspaceStateTransitionAnimation.java    License: GNU General Public License v3.0 5 votes vote down vote up
public AnimatorSet getAnimationToState(Workspace.State fromState, Workspace.State toState,
        int toPage, boolean animated, HashMap<View, Integer> layerViews) {
    AccessibilityManager am = (AccessibilityManager)
            mLauncher.getSystemService(Context.ACCESSIBILITY_SERVICE);
    final boolean accessibilityEnabled = am.isEnabled();
    TransitionStates states = new TransitionStates(fromState, toState);
    int workspaceDuration = getAnimationDuration(states);
    animateWorkspace(states, toPage, animated, workspaceDuration, layerViews,
            accessibilityEnabled);
    animateBackgroundGradient(states, animated, BACKGROUND_FADE_OUT_DURATION);
    return mStateAnimator;
}
 
Example #30
Source Project: 365browser   Author: mogoweb   File: InfoBarContainerLayout.java    License: Apache License 2.0 5 votes vote down vote up
@Override
Animator createAnimator() {
    // The amount by which mNewFrontWrapper will grow (negative value indicates shrinking).
    int deltaHeight = (mNewFrontWrapper.getHeight() - mBackInfobarHeight)
            - mOldFrontWrapper.getHeight();
    int startTranslationY = Math.max(deltaHeight, 0);
    int endTranslationY = Math.max(-deltaHeight, 0);

    // Slide the front infobar down and away.
    AnimatorSet animator = new AnimatorSet();
    mOldFrontWrapper.setTranslationY(startTranslationY);
    animator.play(createTranslationYAnimator(mOldFrontWrapper,
            startTranslationY + mOldFrontWrapper.getHeight())
            .setDuration(DURATION_SLIDE_UP_MS));

    // Slide the other infobars to their new positions.
    // Note: animator.play() causes these animations to run simultaneously.
    for (int i = 1; i < mInfoBarWrappers.size(); i++) {
        mInfoBarWrappers.get(i).setTranslationY(startTranslationY);
        animator.play(createTranslationYAnimator(mInfoBarWrappers.get(i),
                endTranslationY).setDuration(DURATION_SLIDE_UP_MS));
    }

    mNewFrontContents.setAlpha(0f);
    animator.play(ObjectAnimator.ofFloat(mNewFrontContents, View.ALPHA, 1f)
            .setDuration(DURATION_FADE_MS)).after(DURATION_SLIDE_UP_MS);

    return animator;
}