Example usage for android.animation AnimatorSet AnimatorSet

List of usage examples for android.animation AnimatorSet AnimatorSet

Introduction

In this page you can find the example usage for android.animation AnimatorSet AnimatorSet.

Prototype

public AnimatorSet() 

Source Link

Usage

From source file:com.waz.zclient.pages.main.participants.ParticipantFragment.java

@Override
public void onHidePickUser(IPickUserController.Destination destination, boolean closeWithoutSelectingPeople) {
    if (LayoutSpec.isPhone(getActivity())) {
        return;/*from   w w  w  .  j a  v  a  2 s . c  o m*/
    }
    if (!destination.equals(getCurrentPickerDestination())) {
        return;
    }
    // Workaround for animation bug with nested child fragments
    // Animating fragment container views and then popping stack at end of animation

    int showParticipantsDelay = getResources().getInteger(R.integer.framework_animation_delay_long);
    int hidePickUserAnimDuration = getResources().getInteger(R.integer.framework_animation_duration_medium);
    TimeInterpolator hidePickUserInterpolator = new Expo.EaseIn();
    ObjectAnimator hidePickUserAnimator;
    // Fade animation in participants dialog on tablet
    if (LayoutSpec.isTablet(getActivity())) {
        hidePickUserAnimator = ObjectAnimator.ofFloat(pickUserContainerView, View.ALPHA, 1f, 0f);
        hidePickUserAnimator.setInterpolator(new Linear.EaseIn());

    } else {
        hidePickUserAnimator = ObjectAnimator.ofFloat(pickUserContainerView, View.TRANSLATION_Y, 0f,
                pickUserContainerView.getMeasuredHeight());
        hidePickUserAnimator.setInterpolator(hidePickUserInterpolator);
        hidePickUserAnimator.setDuration(hidePickUserAnimDuration);
    }
    hidePickUserAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (!isResumed()) {
                return;
            }
            getChildFragmentManager().popBackStackImmediate(PickUserFragment.TAG,
                    FragmentManager.POP_BACK_STACK_INCLUSIVE);

            if (LayoutSpec.isTablet(getActivity())) {
                // Reset for fade animation in participants dialog on tablet
                pickUserContainerView.setAlpha(1f);
            } else {
                pickUserContainerView.setTranslationY(0f);
            }
        }
    });

    participantsContainerView.setAlpha(0);
    participantsContainerView.setVisibility(View.VISIBLE);
    ObjectAnimator showParticipantsAnimator = ObjectAnimator.ofFloat(participantsContainerView, View.ALPHA, 0f,
            1f);
    showParticipantsAnimator.setInterpolator(new Quart.EaseOut());
    showParticipantsAnimator
            .setDuration(getResources().getInteger(R.integer.framework_animation_duration_medium));
    showParticipantsAnimator.setStartDelay(showParticipantsDelay);

    AnimatorSet hideSet = new AnimatorSet();
    hideSet.playTogether(hidePickUserAnimator, showParticipantsAnimator);
    hideSet.start();

    if (LayoutSpec.isPhone(getActivity()) && getControllerFactory().getNavigationController()
            .getPagerPosition() == NavigationController.SECOND_PAGE) {
        // TODO: https://wearezeta.atlassian.net/browse/AN-3081
        if (getControllerFactory().getConversationScreenController().isShowingParticipant()) {
            getControllerFactory().getNavigationController().setRightPage(Page.PARTICIPANT, TAG);
        } else {
            getControllerFactory().getNavigationController().setRightPage(Page.MESSAGE_STREAM, TAG);
        }
    }
}

From source file:com.stanleyidesis.quotograph.ui.activity.LWQSettingsActivity.java

void animateWallpaperActions(final boolean dismiss) {
    AnimatorSet animatorSet = new AnimatorSet();
    Animator shareButtonAnimator = generateAnimator(shareButton, dismiss, 0);
    animatorSet.playTogether(shareButtonAnimator, generateAnimator(saveButton, dismiss, 20),
            generateAnimator(skipButton, dismiss, 35));
    animatorSet.start();//from   w w w . j  a  va  2  s. c om
}

From source file:org.telegram.ui.Components.ChatAttachAlert.java

private void hideHint() {
    if (hideHintRunnable != null) {
        AndroidUtilities.cancelRunOnUIThread(hideHintRunnable);
        hideHintRunnable = null;/*www .j a  v  a 2 s . co m*/
    }
    if (hintTextView == null) {
        return;
    }
    currentHintAnimation = new AnimatorSet();
    currentHintAnimation.playTogether(ObjectAnimator.ofFloat(hintTextView, "alpha", 0.0f));
    currentHintAnimation.setInterpolator(decelerateInterpolator);
    currentHintAnimation.addListener(new AnimatorListenerAdapterProxy() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (currentHintAnimation == null || !currentHintAnimation.equals(animation)) {
                return;
            }
            currentHintAnimation = null;
            if (hintTextView != null) {
                hintTextView.setVisibility(View.INVISIBLE);
            }
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            if (currentHintAnimation != null && currentHintAnimation.equals(animation)) {
                currentHintAnimation = null;
            }
        }
    });
    currentHintAnimation.setDuration(300);
    currentHintAnimation.start();
}

From source file:org.telegram.ui.Components.ChatActivityEnterView.java

private void setRecordVideoButtonVisible(boolean visible, boolean animated) {
    if (!hasRecordVideo) {
        return;//from   ww w  .j  av  a  2  s  .co m
    }
    videoSendButton.setTag(visible ? 1 : null);
    if (audioVideoButtonAnimation != null) {
        audioVideoButtonAnimation.cancel();
        audioVideoButtonAnimation = null;
    }
    if (animated) {
        audioVideoButtonAnimation = new AnimatorSet();
        audioVideoButtonAnimation.playTogether(
                ObjectAnimator.ofFloat(videoSendButton, "scaleX", visible ? 1.0f : 0.1f),
                ObjectAnimator.ofFloat(videoSendButton, "scaleY", visible ? 1.0f : 0.1f),
                ObjectAnimator.ofFloat(videoSendButton, "alpha", visible ? 1.0f : 0.0f),
                ObjectAnimator.ofFloat(audioSendButton, "scaleX", visible ? 0.1f : 1.0f),
                ObjectAnimator.ofFloat(audioSendButton, "scaleY", visible ? 0.1f : 1.0f),
                ObjectAnimator.ofFloat(audioSendButton, "alpha", visible ? 0.0f : 1.0f));
        audioVideoButtonAnimation.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                if (animation.equals(audioVideoButtonAnimation)) {
                    audioVideoButtonAnimation = null;
                }
            }
        });
        audioVideoButtonAnimation.setInterpolator(new DecelerateInterpolator());
        audioVideoButtonAnimation.setDuration(150);
        audioVideoButtonAnimation.start();
    } else {
        videoSendButton.setScaleX(visible ? 1.0f : 0.1f);
        videoSendButton.setScaleY(visible ? 1.0f : 0.1f);
        videoSendButton.setAlpha(visible ? 1.0f : 0.0f);
        audioSendButton.setScaleX(visible ? 0.1f : 1.0f);
        audioSendButton.setScaleY(visible ? 0.1f : 1.0f);
        audioSendButton.setAlpha(visible ? 0.0f : 1.0f);
    }
}

From source file:com.stanleyidesis.quotograph.ui.activity.LWQSettingsActivity.java

Animator animateFAB(final View fabToAnimate, final boolean dismiss) {
    fabToAnimate.setVisibility(View.VISIBLE);
    float[] toFrom = dismiss ? new float[] { 1f, .2f } : new float[] { .2f, 1f };
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override/*from  w  ww  .j a v a2s.com*/
        public void onAnimationEnd(Animator animation) {
            fabToAnimate.setVisibility(dismiss ? View.GONE : View.VISIBLE);
        }
    });
    ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(fabToAnimate, "alpha", toFrom);
    alphaAnimator.setDuration(200);
    alphaAnimator.setInterpolator(new AccelerateDecelerateInterpolator());

    // Create a scale + fade animation
    ObjectAnimator scaleDown = ObjectAnimator.ofPropertyValuesHolder(fabToAnimate,
            PropertyValuesHolder.ofFloat("scaleX", toFrom), PropertyValuesHolder.ofFloat("scaleY", toFrom));
    scaleDown.setDuration(200);
    scaleDown.setInterpolator(new AccelerateDecelerateInterpolator());
    animatorSet.playTogether(scaleDown, alphaAnimator);
    return animatorSet;
}

From source file:com.arlib.floatingsearchview.FloatingSearchView.java

private void transitionInLeftSection(boolean withAnim) {

    if (mSearchProgress.getVisibility() != View.VISIBLE) {
        mLeftAction.setVisibility(View.VISIBLE);
    } else {/*from w  ww. java 2 s . co m*/
        mLeftAction.setVisibility(View.INVISIBLE);
    }

    switch (mLeftActionMode) {
    case LEFT_ACTION_MODE_SHOW_HAMBURGER:
        openMenuDrawable(mMenuBtnDrawable, withAnim);
        if (!mMenuOpen) {
            break;
        }
        break;
    case LEFT_ACTION_MODE_SHOW_SEARCH:
        mLeftAction.setImageDrawable(mIconBackArrow);
        if (withAnim) {
            mLeftAction.setRotation(45);
            mLeftAction.setAlpha(0.0f);
            ObjectAnimator rotateAnim = ViewPropertyObjectAnimator.animate(mLeftAction).rotation(0).get();
            ObjectAnimator fadeAnim = ViewPropertyObjectAnimator.animate(mLeftAction).alpha(1.0f).get();
            AnimatorSet animSet = new AnimatorSet();
            animSet.setDuration(500);
            animSet.playTogether(rotateAnim, fadeAnim);
            animSet.start();
        }
        break;
    case LEFT_ACTION_MODE_SHOW_HOME:
        //do nothing
        break;
    case LEFT_ACTION_MODE_NO_LEFT_ACTION:
        mLeftAction.setImageDrawable(mIconBackArrow);

        if (withAnim) {
            ObjectAnimator searchInputTransXAnim = ViewPropertyObjectAnimator.animate(mSearchInputParent)
                    .translationX(0).get();

            mLeftAction.setScaleX(0.5f);
            mLeftAction.setScaleY(0.5f);
            mLeftAction.setAlpha(0.0f);
            mLeftAction.setTranslationX(Util.dpToPx(8));
            ObjectAnimator transXArrowAnim = ViewPropertyObjectAnimator.animate(mLeftAction).translationX(1.0f)
                    .get();
            ObjectAnimator scaleXArrowAnim = ViewPropertyObjectAnimator.animate(mLeftAction).scaleX(1.0f).get();
            ObjectAnimator scaleYArrowAnim = ViewPropertyObjectAnimator.animate(mLeftAction).scaleY(1.0f).get();
            ObjectAnimator fadeArrowAnim = ViewPropertyObjectAnimator.animate(mLeftAction).alpha(1.0f).get();
            transXArrowAnim.setStartDelay(150);
            scaleXArrowAnim.setStartDelay(150);
            scaleYArrowAnim.setStartDelay(150);
            fadeArrowAnim.setStartDelay(150);

            AnimatorSet animSet = new AnimatorSet();
            animSet.setDuration(500);
            animSet.playTogether(searchInputTransXAnim, transXArrowAnim, scaleXArrowAnim, scaleYArrowAnim,
                    fadeArrowAnim);
            animSet.start();
        } else {
            mSearchInputParent.setTranslationX(0);
        }
        break;
    }
}

From source file:com.aimfire.demo.CamcorderActivity.java

/**
 * Style 1 animation will simulate a determinate loading
 *
 * @return Animator//w w  w  . ja va 2  s.  com
 */
private Animator prepare3DAnimator() {
    final AnimatorSet animatorSet = new AnimatorSet();

    mScanProgDrawable.setIndeterminate(false);
    mScanProgDrawable.setUseRotation(false);
    mScanProgDrawable.setUseArc(false);
    mScanProgDrawable.setUseAlpha(false);
    mScanProgDrawable.setUseWifiBar(true);

    mScanProgDrawable.setMessageText(getString(R.string.scanning));
    mScanProgDrawable.setSuppText(getString(R.string.tap_to_stop));

    //if(!mScanProgDrawable.getMessageText().equals(getString(R.string.connecting)))
    //{
    //mScanProgDrawable.setMessageText(getString(R.string.scanning) + (mAnimCyclesCnt+1) + " of " + CONNECT_ANIM_CYCLES);
    //}

    Animator determinateAnimator = ObjectAnimator.ofFloat(mScanProgDrawable,
            CircularProgressDrawable.PROGRESS_PROPERTY, 0, 1);
    determinateAnimator.setDuration(CONNECT_ANIM_CYCLE_LENGTH_SECONDS * 1000);

    /*
     * wifi bar highlight changes 3 times a second
     */
    Animator wifiBarAnimator = ObjectAnimator.ofInt(mScanProgDrawable,
            CircularProgressDrawable.WIFI_BAR_PROPERTY, 0, 2 * CONNECT_ANIM_CYCLE_LENGTH_SECONDS);
    wifiBarAnimator.setDuration(CONNECT_ANIM_CYCLE_LENGTH_SECONDS * 1000);
    wifiBarAnimator.setInterpolator(new LinearInterpolator());

    animatorSet.playTogether(wifiBarAnimator, determinateAnimator);

    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animator) {
            restartScanAnim();
        }
    });

    return animatorSet;
}

From source file:org.telegram.ui.Components.ChatAttachAlert.java

@TargetApi(16)
private void openCamera() {
    if (cameraView == null) {
        return;/*from  w  w  w  .jav a  2s. c o m*/
    }
    animateCameraValues[0] = 0;
    animateCameraValues[1] = AndroidUtilities.dp(80) - cameraViewOffsetX;
    animateCameraValues[2] = AndroidUtilities.dp(80) - cameraViewOffsetY;
    cameraAnimationInProgress = true;
    cameraPanel.setVisibility(View.VISIBLE);
    cameraPanel.setTag(null);
    ArrayList<Animator> animators = new ArrayList<>();
    animators.add(ObjectAnimator.ofFloat(ChatAttachAlert.this, "cameraOpenProgress", 0.0f, 1.0f));
    animators.add(ObjectAnimator.ofFloat(cameraPanel, "alpha", 1.0f));
    for (int a = 0; a < 2; a++) {
        if (flashModeButton[a].getVisibility() == View.VISIBLE) {
            animators.add(ObjectAnimator.ofFloat(flashModeButton[a], "alpha", 1.0f));
            break;
        }
    }
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(animators);
    animatorSet.setDuration(200);
    animatorSet.addListener(new AnimatorListenerAdapterProxy() {
        @Override
        public void onAnimationEnd(Animator animator) {
            cameraAnimationInProgress = false;
        }
    });
    animatorSet.start();
    if (Build.VERSION.SDK_INT >= 21) {
        cameraView
                .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_FULLSCREEN);
    }
    cameraOpened = true;
}

From source file:com.mishiranu.dashchan.ui.navigator.NavigatorActivity.java

private void showScaleAnimation(boolean post) {
    clearListAnimator();/*from w w w.j a  va  2 s  . co  m*/
    if (allowScaleAnimation) {
        if (post) {
            listView.setVisibility(View.INVISIBLE);
            handler.post(showScaleRunnable);
        } else {
            final float fromScale = 0.925f;
            ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(listView, View.ALPHA, 0f, 1f);
            ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(listView, View.SCALE_X, fromScale, 1f);
            ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(listView, View.SCALE_Y, fromScale, 1f);
            AnimatorSet animatorSet = new AnimatorSet();
            animatorSet.playTogether(alphaAnimator, scaleXAnimator, scaleYAnimator);
            animatorSet.setDuration(100);
            startListAnimator(animatorSet);
        }
    }
}

From source file:android.support.v17.leanback.app.GuidedStepFragment.java

private void runImeAnimations(boolean entering) {
    ArrayList<Animator> animators = new ArrayList<Animator>();
    if (entering) {
        mGuidanceStylist.onImeAppearing(animators);
        mActionsStylist.onImeAppearing(animators);
        mButtonActionsStylist.onImeAppearing(animators);
    } else {/*from  w ww.  j a  v  a2  s .  co m*/
        mGuidanceStylist.onImeDisappearing(animators);
        mActionsStylist.onImeDisappearing(animators);
        mButtonActionsStylist.onImeDisappearing(animators);
    }
    AnimatorSet set = new AnimatorSet();
    set.playTogether(animators);
    set.start();
}