Example usage for android.animation ObjectAnimator ofFloat

List of usage examples for android.animation ObjectAnimator ofFloat

Introduction

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

Prototype

public static <T> ObjectAnimator ofFloat(T target, Property<T, Float> xProperty, Property<T, Float> yProperty,
        Path path) 

Source Link

Document

Constructs and returns an ObjectAnimator that animates coordinates along a Path using two properties.

Usage

From source file:com.waz.zclient.ui.cursor.CursorLayout.java

private ObjectAnimator getHideToolbarAnimator(final View view, float fromValue, float toValue) {
    ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, fromValue, toValue);
    animator.setDuration(cursorToolbarAnimationDuration);
    animator.setInterpolator(new Expo.EaseIn());
    animator.addListener(new AnimatorListenerAdapter() {
        @Override/*from   ww  w  .j  av  a2s  .  c o  m*/
        public void onAnimationCancel(Animator animation) {
            if (view == null) {
                return;
            }
            view.setVisibility(GONE);
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (view == null) {
                return;
            }
            view.setVisibility(GONE);
        }
    });
    return animator;
}

From source file:com.android.tv.settings.dialog.SettingsLayoutFragment.java

private void fadeIn(View v) {
    ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(v, "alpha", FADE_IN_ALPHA_START,
            FADE_IN_ALPHA_FINISH);/*w  ww  .  j a  v a 2s  .c o m*/
    alphaAnimator
            .setDuration(v.getContext().getResources().getInteger(android.R.integer.config_mediumAnimTime));
    alphaAnimator.start();
}

From source file:com.btmura.android.reddit.app.AbstractBrowserActivity.java

private AnimatorSet newCloseNavAnimator() {
    ObjectAnimator ncTransX = ObjectAnimator.ofFloat(navContainer, "translationX", 0, -leftWidth);

    AnimatorSet as = new AnimatorSet();
    as.setDuration(durationMs).play(ncTransX);
    as.addListener(new AnimatorListenerAdapter() {
        @Override//from  w  w w .  ja  v  a2s  .c o m
        public void onAnimationStart(Animator animation) {
            navContainer.setLayerType(View.LAYER_TYPE_HARDWARE, null);
            navContainer.setVisibility(View.VISIBLE);
            thingContainer.setLayerType(View.LAYER_TYPE_HARDWARE, null);
            thingContainer.setVisibility(View.GONE);
            thingContainer.setTranslationX(0);
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            navContainer.setLayerType(View.LAYER_TYPE_NONE, null);
            navContainer.setVisibility(View.GONE);
            thingContainer.setLayerType(View.LAYER_TYPE_NONE, null);
            thingContainer.setVisibility(View.VISIBLE);
        }
    });
    return as;
}

From source file:com.waz.zclient.pages.main.conversation.SingleImageFragment.java

private AnimatorSet getSaveImageAnimation(final ImageAsset image) {
    int totalAnimationDuration = getResources().getInteger(R.integer.framework_animation_duration_long);

    ObjectAnimator fadeOutAnimator = ObjectAnimator.ofFloat(saveImageViewContainer, View.ALPHA, 1, 0);
    fadeOutAnimator.setDuration(totalAnimationDuration);

    ObjectAnimator scaleDownXAnimator = ObjectAnimator.ofFloat(saveImageViewContainer, View.SCALE_X, 0f);
    ObjectAnimator scaleDownYAnimator = ObjectAnimator.ofFloat(saveImageViewContainer, View.SCALE_Y, 0f);
    scaleDownXAnimator.setDuration(totalAnimationDuration);
    scaleDownYAnimator.setDuration(totalAnimationDuration);

    int moveY = ViewUtils.getOrientationIndependentDisplayHeight(getActivity()) / 2;
    int moveX;/* w  w  w  .  j  a v  a 2 s . c o m*/
    if (ViewUtils.isInLandscape(getActivity())) {
        moveX = ViewUtils.getOrientationIndependentDisplayWidth(getActivity());
    } else {
        moveX = ViewUtils.getOrientationIndependentDisplayWidth(getActivity()) / 2;
    }
    ObjectAnimator moveXAnimator = ObjectAnimator.ofFloat(saveImageViewContainer, View.TRANSLATION_X, -moveX);
    ObjectAnimator moveYAnimator = ObjectAnimator.ofFloat(saveImageViewContainer, View.TRANSLATION_Y, moveY);
    moveXAnimator.setDuration(totalAnimationDuration);
    moveYAnimator.setDuration(totalAnimationDuration);

    // Fade out top image view for blur effect
    ObjectAnimator fadeToBlurredAnimator = ObjectAnimator.ofFloat(saveImageView, View.ALPHA, 1, 0);
    fadeToBlurredAnimator.setDuration(getResources().getInteger(R.integer.framework_animation_duration_medium));

    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.setInterpolator(new Expo.EaseIn());
    animatorSet.playTogether(fadeOutAnimator, scaleDownXAnimator, scaleDownYAnimator, moveXAnimator,
            moveYAnimator, fadeToBlurredAnimator);

    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (getStoreFactory() == null || getStoreFactory().isTornDown()) {
                return;
            }

            resetSaveImageView();

            // Image saving is called here, as an image save triggers a notification which contains a bitmap;
            // currently that bitmap is quite large, android.app.Notification writes the bitmap to a parcel
            // on the main thread, dropping a large number of frames and breaking the save animation
            image.saveImageToGallery(SingleImageFragment.this);

            enableSaveImageButton(true);
        }
    });

    return animatorSet;
}

From source file:com.fa.imaged.activity.DetailActivityV2.java

private static void animatePhotoLike() {
    detailvBgLike.setVisibility(View.VISIBLE);
    detailivLike.setVisibility(View.VISIBLE);

    detailvBgLike.setScaleY(0.1f);//  w w  w . j  a va  2s .  c  o  m
    detailvBgLike.setScaleX(0.1f);
    detailvBgLike.setAlpha(1f);
    detailivLike.setScaleY(0.1f);
    detailivLike.setScaleX(0.1f);

    AnimatorSet animatorSet = new AnimatorSet();

    ObjectAnimator bgScaleYAnim = ObjectAnimator.ofFloat(detailvBgLike, "scaleY", 0.1f, 1f);
    bgScaleYAnim.setDuration(200);
    bgScaleYAnim.setInterpolator(DECCELERATE_INTERPOLATOR);
    ObjectAnimator bgScaleXAnim = ObjectAnimator.ofFloat(detailvBgLike, "scaleX", 0.1f, 1f);
    bgScaleXAnim.setDuration(200);
    bgScaleXAnim.setInterpolator(DECCELERATE_INTERPOLATOR);
    ObjectAnimator bgAlphaAnim = ObjectAnimator.ofFloat(detailvBgLike, "alpha", 1f, 0f);
    bgAlphaAnim.setDuration(200);
    bgAlphaAnim.setStartDelay(150);
    bgAlphaAnim.setInterpolator(DECCELERATE_INTERPOLATOR);

    ObjectAnimator imgScaleUpYAnim = ObjectAnimator.ofFloat(detailivLike, "scaleY", 0.1f, 1f);
    imgScaleUpYAnim.setDuration(300);
    imgScaleUpYAnim.setInterpolator(DECCELERATE_INTERPOLATOR);
    ObjectAnimator imgScaleUpXAnim = ObjectAnimator.ofFloat(detailivLike, "scaleX", 0.1f, 1f);
    imgScaleUpXAnim.setDuration(300);
    imgScaleUpXAnim.setInterpolator(DECCELERATE_INTERPOLATOR);

    ObjectAnimator imgScaleDownYAnim = ObjectAnimator.ofFloat(detailivLike, "scaleY", 1f, 0f);
    imgScaleDownYAnim.setDuration(300);
    imgScaleDownYAnim.setInterpolator(ACCELERATE_INTERPOLATOR);
    ObjectAnimator imgScaleDownXAnim = ObjectAnimator.ofFloat(detailivLike, "scaleX", 1f, 0f);
    imgScaleDownXAnim.setDuration(300);
    imgScaleDownXAnim.setInterpolator(ACCELERATE_INTERPOLATOR);

    animatorSet.playTogether(bgScaleYAnim, bgScaleXAnim, bgAlphaAnim, imgScaleUpYAnim, imgScaleUpXAnim);
    animatorSet.play(imgScaleDownYAnim).with(imgScaleDownXAnim).after(imgScaleUpYAnim);

    animatorSet.start();
}

From source file:com.android.deskclock.timer.TimerFullScreenFragment.java

private void gotoTimersView() {
    if (mLastVisibleView == null || mLastVisibleView.getId() == R.id.timers_list_page) {
        mTimerSetup.setVisibility(View.GONE);
        mTimersListPage.setVisibility(View.VISIBLE);
        mTimersListPage.setScaleX(1f);/*  ww  w.  j a  va 2 s.  co m*/
    } else {
        // Animate
        ObjectAnimator a = ObjectAnimator.ofFloat(mTimerSetup, View.SCALE_X, 1f, 0f);
        a.setInterpolator(new AccelerateInterpolator());
        a.setDuration(125);
        a.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                mTimerSetup.setVisibility(View.GONE);
                mTimersListPage.setScaleX(0);
                mTimersListPage.setVisibility(View.VISIBLE);
                ObjectAnimator b = ObjectAnimator.ofFloat(mTimersListPage, View.SCALE_X, 0f, 1f);
                b.setInterpolator(new DecelerateInterpolator());
                b.setDuration(225);
                b.start();
            }
        });
        a.start();
    }
    startClockTicks();
    mLastVisibleView = mTimersListPage;
}

From source file:com.flexible.flexibleadapter.AnimatorAdapter.java

/**
 * Item will slide from Top of the screen to its natural position.<br/>
 * Ignored if LEFT, RIGHT, TOP or BOTTOM animators were already added.
 * <p><b>Note:</b> Only 1 animator of the same compatible type can be added per time.<br/>
 * Incompatible with LEFT, RIGHT, TOP, BOTTOM animators.</p>
 *
 * @param animators user defined list//from w  w  w  . j av  a  2  s .  c  o  m
 * @param view      itemView to animate
 * @since 5.0.0-b7
 * @deprecated Use {@link }.
 */
@Deprecated
public void addSlideInFromTopAnimator(@NonNull List<Animator> animators, @NonNull View view) {
    if (animatorsUsed.contains(AnimatorEnum.SLIDE_IN_LEFT)
            || animatorsUsed.contains(AnimatorEnum.SLIDE_IN_RIGHT)
            || animatorsUsed.contains(AnimatorEnum.SLIDE_IN_TOP)
            || animatorsUsed.contains(AnimatorEnum.SLIDE_IN_BOTTOM))
        return;
    animators.add(ObjectAnimator.ofFloat(view, "translationY", -mRecyclerView.getMeasuredHeight() >> 1, 0));
    animatorsUsed.add(AnimatorEnum.SLIDE_IN_TOP);
}

From source file:com.android.launcher3.folder.Folder.java

public void animateOpen() {
    if (!(getParent() instanceof DragLayer))
        return;//from   w  w w  .  j ava2  s  .  com

    mContent.completePendingPageChanges();
    if (!mDragInProgress) {
        // Open on the first page.
        mContent.snapToPageImmediately(0);
    }

    // This is set to true in close(), but isn't reset to false until onDropCompleted(). This
    // leads to an inconsistent state if you drag out of the folder and drag back in without
    // dropping. One resulting issue is that replaceFolderWithFinalItem() can be called twice.
    mDeleteFolderOnDropCompleted = false;

    Animator openFolderAnim = null;
    final Runnable onCompleteRunnable;
    if (!Utilities.ATLEAST_LOLLIPOP) {
        positionAndSizeAsIcon();
        centerAboutIcon();

        final ObjectAnimator oa = LauncherAnimUtils.ofViewAlphaAndScale(this, 1, 1, 1);
        oa.setDuration(mExpandDuration);
        openFolderAnim = oa;

        setLayerType(LAYER_TYPE_HARDWARE, null);
        onCompleteRunnable = new Runnable() {
            @Override
            public void run() {
                setLayerType(LAYER_TYPE_NONE, null);
            }
        };
    } else {
        prepareReveal();
        centerAboutIcon();

        AnimatorSet anim = LauncherAnimUtils.createAnimatorSet();
        int width = getPaddingLeft() + getPaddingRight() + mContent.getDesiredWidth();
        int height = getFolderHeight();

        float transX = -0.075f * (width / 2 - getPivotX());
        float transY = -0.075f * (height / 2 - getPivotY());
        setTranslationX(transX);
        setTranslationY(transY);
        PropertyValuesHolder tx = PropertyValuesHolder.ofFloat(TRANSLATION_X, transX, 0);
        PropertyValuesHolder ty = PropertyValuesHolder.ofFloat(TRANSLATION_Y, transY, 0);

        Animator drift = ObjectAnimator.ofPropertyValuesHolder(this, tx, ty);
        drift.setDuration(mMaterialExpandDuration);
        drift.setStartDelay(mMaterialExpandStagger);
        drift.setInterpolator(new LogDecelerateInterpolator(100, 0));

        int rx = (int) Math.max(Math.max(width - getPivotX(), 0), getPivotX());
        int ry = (int) Math.max(Math.max(height - getPivotY(), 0), getPivotY());
        float radius = (float) Math.hypot(rx, ry);

        Animator reveal = new CircleRevealOutlineProvider((int) getPivotX(), (int) getPivotY(), 0, radius)
                .createRevealAnimator(this);
        reveal.setDuration(mMaterialExpandDuration);
        reveal.setInterpolator(new LogDecelerateInterpolator(100, 0));

        mContent.setAlpha(0f);
        Animator iconsAlpha = ObjectAnimator.ofFloat(mContent, "alpha", 0f, 1f);
        iconsAlpha.setDuration(mMaterialExpandDuration);
        iconsAlpha.setStartDelay(mMaterialExpandStagger);
        iconsAlpha.setInterpolator(new AccelerateInterpolator(1.5f));

        mFooter.setAlpha(0f);
        Animator textAlpha = ObjectAnimator.ofFloat(mFooter, "alpha", 0f, 1f);
        textAlpha.setDuration(mMaterialExpandDuration);
        textAlpha.setStartDelay(mMaterialExpandStagger);
        textAlpha.setInterpolator(new AccelerateInterpolator(1.5f));

        anim.play(drift);
        anim.play(iconsAlpha);
        anim.play(textAlpha);
        anim.play(reveal);

        openFolderAnim = anim;

        mContent.setLayerType(LAYER_TYPE_HARDWARE, null);
        mFooter.setLayerType(LAYER_TYPE_HARDWARE, null);
        onCompleteRunnable = new Runnable() {
            @Override
            public void run() {
                mContent.setLayerType(LAYER_TYPE_NONE, null);
                mFooter.setLayerType(LAYER_TYPE_NONE, null);
                mLauncher.getUserEventDispatcher().resetElapsedContainerMillis();
            }
        };
    }
    openFolderAnim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            Utilities.sendCustomAccessibilityEvent(Folder.this, AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED,
                    mContent.getAccessibilityDescription());
            mState = STATE_ANIMATING;
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            mState = STATE_OPEN;

            onCompleteRunnable.run();
            mContent.setFocusOnFirstChild();
        }
    });

    // Footer animation
    if (mContent.getPageCount() > 1 && !mInfo.hasOption(FolderInfo.FLAG_MULTI_PAGE_ANIMATION)) {
        int footerWidth = mContent.getDesiredWidth() - mFooter.getPaddingLeft() - mFooter.getPaddingRight();

        float textWidth = mFolderName.getPaint().measureText(mFolderName.getText().toString());
        float translation = (footerWidth - textWidth) / 2;
        mFolderName.setTranslationX(mContent.mIsRtl ? -translation : translation);
        mPageIndicator.prepareEntryAnimation();

        // Do not update the flag if we are in drag mode. The flag will be updated, when we
        // actually drop the icon.
        final boolean updateAnimationFlag = !mDragInProgress;
        openFolderAnim.addListener(new AnimatorListenerAdapter() {

            @SuppressLint("InlinedApi")
            @Override
            public void onAnimationEnd(Animator animation) {
                mFolderName.animate().setDuration(FOLDER_NAME_ANIMATION_DURATION).translationX(0)
                        .setInterpolator(Utilities.ATLEAST_LOLLIPOP
                                ? AnimationUtils.loadInterpolator(mLauncher,
                                        android.R.interpolator.fast_out_slow_in)
                                : new LogDecelerateInterpolator(100, 0));
                mPageIndicator.playEntryAnimation();

                if (updateAnimationFlag) {
                    mInfo.setOption(FolderInfo.FLAG_MULTI_PAGE_ANIMATION, true, mLauncher);
                }
            }
        });
    } else {
        mFolderName.setTranslationX(0);
    }

    mPageIndicator.stopAllAnimations();
    openFolderAnim.start();

    // Make sure the folder picks up the last drag move even if the finger doesn't move.
    if (mDragController.isDragging()) {
        mDragController.forceTouchMove();
    }

    mContent.verifyVisibleHighResIcons(mContent.getNextPage());
}

From source file:com.btmura.android.reddit.app.AbstractBrowserActivity.java

private AnimatorSet newCollapseLeftAnimator() {
    ObjectAnimator slTransX = ObjectAnimator.ofFloat(leftContainer, "translationX", 0, -leftWidth);
    ObjectAnimator tlTransX = ObjectAnimator.ofFloat(rightContainer, "translationX", 0, -leftWidth);

    AnimatorSet as = new AnimatorSet();
    as.setDuration(durationMs).play(slTransX).with(tlTransX);
    as.addListener(new AnimatorListenerAdapter() {
        @Override//from   ww w  .j av a 2s.c  om
        public void onAnimationStart(Animator animation) {
            leftContainer.setLayerType(View.LAYER_TYPE_HARDWARE, null);
            leftContainer.setVisibility(View.VISIBLE);
            rightContainer.setLayerType(View.LAYER_TYPE_HARDWARE, null);
            rightContainer.setVisibility(View.VISIBLE);
            thingContainer.setVisibility(View.GONE);
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            leftContainer.setLayerType(View.LAYER_TYPE_NONE, null);
            leftContainer.setVisibility(View.GONE);
            rightContainer.setLayerType(View.LAYER_TYPE_NONE, null);
            rightContainer.setTranslationX(0);
            thingContainer.setVisibility(View.VISIBLE);
        }
    });
    return as;
}

From source file:com.github.shareme.gwsmaterialdrawer.library.DrawerView.java

private void animateToProfile(DrawerProfile profile) {
    Log.d(TAG, "animateToProfile(*" + profile.getId() + ")");

    if (mProfileAdapter.getCount() > 1) {
        List<Animator> animators = new ArrayList<>();
        List<Animator.AnimatorListener> listeners = new ArrayList<>();

        final DrawerProfile oldProfile = mProfileAdapter.getItem(0);
        final DrawerProfile newProfile = profile;

        /* Background animation */

        AlphaSatColorMatrixEvaluator evaluator = new AlphaSatColorMatrixEvaluator();
        final AnimatableColorMatrixColorFilter filter = new AnimatableColorMatrixColorFilter(
                evaluator.getColorMatrix());

        ObjectAnimator backgroundAnimator = ObjectAnimator.ofObject(filter, "colorMatrix", evaluator,
                evaluator.getColorMatrix());
        backgroundAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override//w  ww . j ava 2s  .  co m
            public void onAnimationUpdate(ValueAnimator animation) {
                imageViewProfileBackgroundOverlay.setColorFilter(filter.getColorFilter());
            }
        });
        animators.add(backgroundAnimator);

        listeners.add(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {
                imageViewProfileBackground.setImageDrawable(oldProfile.getBackground());

                imageViewProfileBackgroundOverlay.setImageDrawable(newProfile.getBackground());
                imageViewProfileBackgroundOverlay.setColorFilter(filter.getColorFilter());
                imageViewProfileBackgroundOverlay.setVisibility(VISIBLE);

                imageViewProfileAvatarSecondary.setClickable(false);
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                imageViewProfileBackground.setImageDrawable(newProfile.getBackground());

                if (newProfile.getBackground() instanceof BitmapDrawable) {
                    new Palette.Builder(((BitmapDrawable) newProfile.getBackground()).getBitmap())
                            .resizeBitmapSize(500).generate(new Palette.PaletteAsyncListener() {
                                @Override
                                public void onGenerated(Palette palette) {
                                    Palette.Swatch vibrantSwatch = palette.getVibrantSwatch();
                                    if (vibrantSwatch != null) {
                                        textViewProfileAvatarCount
                                                .setTextColor(vibrantSwatch.getTitleTextColor());
                                        textViewProfileAvatarCount.getBackground()
                                                .setColorFilter(vibrantSwatch.getRgb(), PorterDuff.Mode.SRC_IN);
                                    }
                                }
                            });
                }

                imageViewProfileBackgroundOverlay.setVisibility(GONE);

                if (hasOnProfileSwitchListener()) {
                    onProfileSwitchListener.onSwitch(oldProfile, oldProfile.getId(), newProfile,
                            newProfile.getId());
                }
            }

            @Override
            public void onAnimationCancel(Animator animation) {
            }

            @Override
            public void onAnimationRepeat(Animator animation) {
            }
        });

        /* Text animation */

        AnimatorSet textSet = new AnimatorSet();

        AnimatorSet textOutSet = new AnimatorSet();
        textOutSet.playTogether(ObjectAnimator.ofFloat(linearLayoutProfileTextContainer, "alpha", 1, 0),
                ObjectAnimator.ofFloat(linearLayoutProfileTextContainer, "translationX", 0, getWidth() / 4));
        textOutSet.addListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                updateProfileTheme();
                if (newProfile.hasName()) {
                    textViewProfileName.setText(newProfile.getName());
                    textViewProfileName.setVisibility(VISIBLE);
                } else {
                    textViewProfileName.setVisibility(GONE);
                }
                if (newProfile.hasDescription()) {
                    textViewProfileDescription.setText(newProfile.getDescription());
                    textViewProfileDescription.setVisibility(VISIBLE);
                } else {
                    textViewProfileDescription.setVisibility(GONE);
                }
            }

            @Override
            public void onAnimationCancel(Animator animation) {
            }

            @Override
            public void onAnimationRepeat(Animator animation) {
            }
        });

        AnimatorSet textInSet = new AnimatorSet();
        textInSet.playTogether(ObjectAnimator.ofFloat(linearLayoutProfileTextContainer, "alpha", 0, 1),
                ObjectAnimator.ofFloat(linearLayoutProfileTextContainer, "translationX", -getWidth() / 4, 0));

        textSet.playSequentially(textOutSet, textInSet);
        animators.add(textSet);

        AnimatorSet profileSet = new AnimatorSet();
        if (mProfileAdapter.getCount() == 2) {

            /* Avatar animation */

            int translation = imageViewProfileAvatarSecondary.getLeft()
                    - getResources().getDimensionPixelSize(R.dimen.md_baseline);
            float scale = getResources().getDimension(R.dimen.md_avatar_size)
                    / getResources().getDimension(R.dimen.md_big_avatar_size);
            float translationCorrect = (getResources().getDimension(R.dimen.md_avatar_size)
                    - getResources().getDimension(R.dimen.md_big_avatar_size)) / 2;

            listeners.add(new Animator.AnimatorListener() {
                @Override
                public void onAnimationStart(Animator animation) {
                    imageViewProfileAvatarSecondary.setPivotX(0);
                    imageViewProfileAvatarSecondary.setPivotY(0);
                }

                @Override
                public void onAnimationEnd(Animator animation) {

                    imageViewProfileAvatar.setTranslationX(0);
                    imageViewProfileAvatar.setTranslationY(0);
                    imageViewProfileAvatar.setScaleX(1);
                    imageViewProfileAvatar.setScaleY(1);
                    imageViewProfileAvatarSecondary.setTranslationX(0);
                    imageViewProfileAvatarSecondary.setScaleX(1);
                    imageViewProfileAvatarSecondary.setScaleY(1);

                    if (oldProfile.hasAvatar()) {

                        imageViewProfileAvatarSecondary.setImageDrawable(oldProfile.getAvatar());
                        imageViewProfileAvatarSecondary.setVisibility(VISIBLE);
                    } else {
                        imageViewProfileAvatarSecondary.setVisibility(INVISIBLE);
                    }

                    if (newProfile.hasAvatar()) {

                        imageViewProfileAvatar.setImageDrawable(newProfile.getAvatar());
                        imageViewProfileAvatar.setVisibility(VISIBLE);
                        imageViewProfileAvatarSecondary.setClickable(true);
                    } else {
                        imageViewProfileAvatar.setVisibility(INVISIBLE);
                        imageViewProfileAvatarSecondary.setClickable(false);
                    }
                }

                @Override
                public void onAnimationCancel(Animator animation) {
                }

                @Override
                public void onAnimationRepeat(Animator animation) {
                }
            });
            if (oldProfile.hasAvatar()) {

                ObjectAnimator stepTranslateXAnimator = ObjectAnimator.ofFloat(imageViewProfileAvatar,
                        "translationX", 0, translation + translationCorrect);
                stepTranslateXAnimator.setInterpolator(new StepInterpolator());
                animators.add(stepTranslateXAnimator);

                ObjectAnimator stepTranslateYAnimator = ObjectAnimator.ofFloat(imageViewProfileAvatar,
                        "translationY", 0, translationCorrect);
                stepTranslateYAnimator.setInterpolator(new StepInterpolator());
                animators.add(stepTranslateYAnimator);

                animators.add(ObjectAnimator.ofFloat(imageViewProfileAvatar, "alpha", 1, 0, 1));
                animators.add(ObjectAnimator.ofFloat(imageViewProfileAvatar, "scaleX", 1, 0.5f, scale));
                animators.add(ObjectAnimator.ofFloat(imageViewProfileAvatar, "scaleY", 1, 0.5f, scale));
            }

            if (newProfile.hasAvatar()) {
                animators.add(ObjectAnimator.ofFloat(imageViewProfileAvatarSecondary, "translationX", 0,
                        -translation));
                animators.add(ObjectAnimator.ofFloat(imageViewProfileAvatarSecondary, "scaleX", 1, 1 / scale));
                animators.add(ObjectAnimator.ofFloat(imageViewProfileAvatarSecondary, "scaleY", 1, 1 / scale));
            }
        } else {
            AnimatorSet profileOutSet = new AnimatorSet();
            profileOutSet.playTogether(ObjectAnimator.ofFloat(imageViewProfileAvatar, "alpha", 1, 0),
                    ObjectAnimator.ofFloat(imageViewProfileAvatar, "scaleX", 1, 0.5f),
                    ObjectAnimator.ofFloat(imageViewProfileAvatar, "scaleY", 1, 0.5f));
            profileOutSet.addListener(new Animator.AnimatorListener() {
                @Override
                public void onAnimationStart(Animator animation) {
                    linearListViewProfileList.setOnItemClickListener(new LinearListView.OnItemClickListener() {
                        @Override
                        public void onItemClick(LinearListView parent, View view, int position, long id) {
                        }
                    });
                }

                @Override
                public void onAnimationEnd(Animator animation) {
                    imageViewProfileAvatar.setImageDrawable(newProfile.getAvatar());

                    linearListViewProfileList.setOnItemClickListener(new LinearListView.OnItemClickListener() {
                        @Override
                        public void onItemClick(LinearListView parent, View view, int position, long id) {
                            if (position != 0) {
                                selectProfile(mProfileAdapter.getItem(position));
                            }
                        }
                    });
                }

                @Override
                public void onAnimationCancel(Animator animation) {
                }

                @Override
                public void onAnimationRepeat(Animator animation) {
                }
            });

            AnimatorSet profileInSet = new AnimatorSet();
            profileInSet.playTogether(ObjectAnimator.ofFloat(imageViewProfileAvatar, "alpha", 0, 1),
                    ObjectAnimator.ofFloat(imageViewProfileAvatar, "scaleX", 0.5f, 1),
                    ObjectAnimator.ofFloat(imageViewProfileAvatar, "scaleY", 0.5f, 1));

            profileSet.playSequentially(profileOutSet, profileInSet);
            animators.add(profileSet);
        }
        if (animators.size() > 0) {
            /* Play animation */
            AnimatorSet set = new AnimatorSet();
            set.playTogether(animators);
            set.setDuration(getResources().getInteger(R.integer.md_profile_switching_anim_time));
            textSet.setDuration(getResources().getInteger(R.integer.md_profile_switching_anim_time) / 2);
            profileSet.setDuration(getResources().getInteger(R.integer.md_profile_switching_anim_time) / 2);
            for (Animator.AnimatorListener listener : listeners) {
                set.addListener(listener);
            }
            set.start();
        }
    }
}