Example usage for android.view View TRANSLATION_Y

List of usage examples for android.view View TRANSLATION_Y

Introduction

In this page you can find the example usage for android.view View TRANSLATION_Y.

Prototype

Property TRANSLATION_Y

To view the source code for android.view View TRANSLATION_Y.

Click Source Link

Document

A Property wrapper around the translationY functionality handled by the View#setTranslationY(float) and View#getTranslationY() methods.

Usage

From source file:com.tiancaicc.springfloatingactionmenu.SpringFloatingActionMenu.java

private void applyFollowAnimation() {
    /* Animation code */

    final SpringSystem springSystem = SpringSystem.create();

    // create the springs that control movement
    final Spring springX = springSystem.createSpring();
    final Spring springY = springSystem.createSpring();

    // bind circle movement to events
    new Actor.Builder(springSystem, mFAB)
            .addMotion(springX, Imitator.TRACK_DELTA, Imitator.FOLLOW_EXACT, MotionProperty.X)
            .addMotion(springY, Imitator.TRACK_DELTA, Imitator.FOLLOW_EXACT, MotionProperty.Y).build();

    // add springs to connect between the views
    final Spring[] followsX = new Spring[mMenuItemCount];
    final Spring[] followsY = new Spring[mMenuItemCount];

    for (int i = 0; i < mFollowCircles.size(); i++) {

        // create spring to bind views
        followsX[i] = springSystem.createSpring();
        followsY[i] = springSystem.createSpring();
        followsX[i].addListener(new Performer(mFollowCircles.get(i), View.TRANSLATION_X));
        followsY[i].addListener(new Performer(mFollowCircles.get(i), View.TRANSLATION_Y));

        // imitates another character
        final SpringImitator followX = new SpringImitator(followsX[i]);
        final SpringImitator followY = new SpringImitator(followsY[i]);

        //  imitate the previous character
        if (i == 0) {
            springX.addListener(followX);
            springY.addListener(followY);
        } else {/*  ww w. j av a2  s . c o m*/
            followsX[i - 1].addListener(followX);
            followsY[i - 1].addListener(followY);
        }
    }
}

From source file:com.pitchedapps.primenumbercalculator.Calculator.java

License:asdf

private void onResult(final String result) {
    // Calculate the values needed to perform the scale and translation animations,
    // accounting for how the scale will affect the final position of the text.
    final float resultScale = mInputEditText.getVariableTextSize(result) / mResultEditText.getTextSize();
    final float resultTranslationX = (1.0f - resultScale)
            * (mResultEditText.getWidth() / 2.0f - mResultEditText.getPaddingEnd());
    final float resultTranslationY = (1.0f - resultScale) * //TODO delete unnecessary lines for animation
            (mResultEditText.getHeight() / 2.0f - mResultEditText.getPaddingBottom())
            + (mInputEditText.getBottom() - mResultEditText.getBottom())
            + (mResultEditText.getPaddingBottom() - mInputEditText.getPaddingBottom());
    final float inputTranslationY = -mInputEditText.getBottom();

    // Use a value animator to fade to the final text color over the course of the animation.
    final int resultTextColor = mResultEditText.getCurrentTextColor();
    final int inputEditText = mInputEditText.getCurrentTextColor();
    final ValueAnimator textColorAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), resultTextColor,
            inputEditText);/*from w  w w . j a v a 2s  .c o m*/
    textColorAnimator.addUpdateListener(new AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            mResultEditText.setTextColor((int) valueAnimator.getAnimatedValue());
        }
    });

    final AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(textColorAnimator,
            ObjectAnimator.ofFloat(mResultEditText, View.SCALE_X, resultScale),
            ObjectAnimator.ofFloat(mResultEditText, View.SCALE_Y, resultScale),
            ObjectAnimator.ofFloat(mResultEditText, View.TRANSLATION_X, resultTranslationX),
            ObjectAnimator.ofFloat(mResultEditText, View.TRANSLATION_Y, resultTranslationY),
            ObjectAnimator.ofFloat(mInputEditText, View.TRANSLATION_Y, inputTranslationY));
    animatorSet.setDuration(getResources().getInteger(android.R.integer.config_longAnimTime));
    animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            mResultEditText.setText(result);
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            // Reset all of the values modified during the animation.
            mResultEditText.setTextColor(resultTextColor);
            mResultEditText.setScaleX(1.0f);
            mResultEditText.setScaleY(1.0f);
            mResultEditText.setTranslationX(0.0f);
            mResultEditText.setTranslationY(0.0f);
            mInputEditText.setTranslationY(0.0f);

            // Finally update the input to use the current result.
            mInputEditText.setText(result); //TODO figure out how to reset after equal sign without changing input text
            mResultEditText.getEditableText().clear();
            setState(CalculatorState.RESULT);

            mCurrentAnimator = null;
        }

    });

    mCurrentAnimator = animatorSet;
    animatorSet.start();
}

From source file:org.mariotaku.twidere.fragment.support.AccountsDashboardFragment.java

private void onAccountSelected(AccountProfileImageViewHolder holder, final ParcelableAccount account) {
    if (mSwitchAccountAnimationPlaying)
        return;//from w w w.  j a v a 2s .  co m
    final ImageView snapshotView = mFloatingProfileImageSnapshotView;
    final ShapedImageView profileImageView = mAccountProfileImageView;
    final ShapedImageView clickedImageView = holder.getIconView();

    // Reset snapshot view position
    snapshotView.setPivotX(0);
    snapshotView.setPivotY(0);
    snapshotView.setTranslationX(0);
    snapshotView.setTranslationY(0);

    final Matrix matrix = new Matrix();
    final RectF sourceBounds = new RectF(), destBounds = new RectF(), snapshotBounds = new RectF();
    getLocationOnScreen(clickedImageView, sourceBounds);
    getLocationOnScreen(profileImageView, destBounds);
    getLocationOnScreen(snapshotView, snapshotBounds);
    final float finalScale = destBounds.width() / sourceBounds.width();
    final Bitmap snapshotBitmap = TransitionUtils.createViewBitmap(clickedImageView, matrix,
            new RectF(0, 0, sourceBounds.width(), sourceBounds.height()));
    final ViewGroup.LayoutParams lp = snapshotView.getLayoutParams();
    lp.width = clickedImageView.getWidth();
    lp.height = clickedImageView.getHeight();
    snapshotView.setLayoutParams(lp);
    // Copied from MaterialNavigationDrawer: https://github.com/madcyph3r/AdvancedMaterialDrawer/
    AnimatorSet set = new AnimatorSet();
    set.play(ObjectAnimator.ofFloat(snapshotView, View.TRANSLATION_X, sourceBounds.left - snapshotBounds.left,
            destBounds.left - snapshotBounds.left))
            .with(ObjectAnimator.ofFloat(snapshotView, View.TRANSLATION_Y,
                    sourceBounds.top - snapshotBounds.top, destBounds.top - snapshotBounds.top))
            .with(ObjectAnimator.ofFloat(snapshotView, View.SCALE_X, 1, finalScale))
            .with(ObjectAnimator.ofFloat(snapshotView, View.SCALE_Y, 1, finalScale))
            .with(ObjectAnimator.ofFloat(profileImageView, View.ALPHA, 1, 0))
            .with(ObjectAnimator.ofFloat(clickedImageView, View.SCALE_X, 0, 1))
            .with(ObjectAnimator.ofFloat(clickedImageView, View.SCALE_Y, 0, 1));
    final long animationTransition = 400;
    set.setDuration(animationTransition);
    set.setInterpolator(new DecelerateInterpolator());
    set.addListener(new AnimatorListener() {

        private Drawable clickedDrawable;
        private int[] clickedColors;

        @Override
        public void onAnimationStart(Animator animation) {
            snapshotView.setVisibility(View.VISIBLE);
            snapshotView.setImageBitmap(snapshotBitmap);
            final Drawable profileDrawable = profileImageView.getDrawable();
            clickedDrawable = clickedImageView.getDrawable();
            clickedColors = clickedImageView.getBorderColors();
            final ParcelableAccount oldSelectedAccount = mAccountsAdapter.getSelectedAccount();
            mImageLoader.displayDashboardProfileImage(clickedImageView, oldSelectedAccount.profile_image_url,
                    profileDrawable);
            //                mImageLoader.displayDashboardProfileImage(profileImageView,
            //                        account.profile_image_url, clickedDrawable);
            clickedImageView.setBorderColors(profileImageView.getBorderColors());
            mSwitchAccountAnimationPlaying = true;
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            finishAnimation();
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            finishAnimation();
        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }

        private void finishAnimation() {
            final Editor editor = mPreferences.edit();
            editor.putLong(KEY_DEFAULT_ACCOUNT_ID, account.account_id);
            editor.apply();
            mAccountsAdapter.setSelectedAccountId(account.account_id);
            mAccountOptionsAdapter.setSelectedAccount(account);
            updateAccountOptionsSeparatorLabel(clickedDrawable);
            snapshotView.setVisibility(View.INVISIBLE);
            snapshotView.setImageDrawable(null);
            profileImageView.setImageDrawable(clickedDrawable);
            profileImageView.setBorderColors(clickedColors);
            profileImageView.setAlpha(1f);
            clickedImageView.setScaleX(1);
            clickedImageView.setScaleY(1);
            clickedImageView.setAlpha(1f);
            mSwitchAccountAnimationPlaying = false;
        }
    });
    set.start();
}

From source file:org.mariotaku.twidere.fragment.AccountsDashboardFragment.java

private void onAccountSelected(AccountProfileImageViewHolder holder, @NonNull final ParcelableAccount account) {
    if (mSwitchAccountAnimationPlaying)
        return;/*from w  w w  .j a va2  s .c o m*/
    final ImageView snapshotView = mFloatingProfileImageSnapshotView;
    final ShapedImageView profileImageView = mAccountProfileImageView;
    final ShapedImageView clickedImageView = holder.getIconView();

    // Reset snapshot view position
    snapshotView.setPivotX(0);
    snapshotView.setPivotY(0);
    snapshotView.setTranslationX(0);
    snapshotView.setTranslationY(0);

    final Matrix matrix = new Matrix();
    final RectF sourceBounds = new RectF(), destBounds = new RectF(), snapshotBounds = new RectF();
    getLocationOnScreen(clickedImageView, sourceBounds);
    getLocationOnScreen(profileImageView, destBounds);
    getLocationOnScreen(snapshotView, snapshotBounds);
    final float finalScale = destBounds.width() / sourceBounds.width();
    final Bitmap snapshotBitmap = TransitionUtils.createViewBitmap(clickedImageView, matrix,
            new RectF(0, 0, sourceBounds.width(), sourceBounds.height()));
    final ViewGroup.LayoutParams lp = snapshotView.getLayoutParams();
    lp.width = clickedImageView.getWidth();
    lp.height = clickedImageView.getHeight();
    snapshotView.setLayoutParams(lp);
    // Copied from MaterialNavigationDrawer: https://github.com/madcyph3r/AdvancedMaterialDrawer/
    AnimatorSet set = new AnimatorSet();
    set.play(ObjectAnimator.ofFloat(snapshotView, View.TRANSLATION_X, sourceBounds.left - snapshotBounds.left,
            destBounds.left - snapshotBounds.left))
            .with(ObjectAnimator.ofFloat(snapshotView, View.TRANSLATION_Y,
                    sourceBounds.top - snapshotBounds.top, destBounds.top - snapshotBounds.top))
            .with(ObjectAnimator.ofFloat(snapshotView, View.SCALE_X, 1, finalScale))
            .with(ObjectAnimator.ofFloat(snapshotView, View.SCALE_Y, 1, finalScale))
            .with(ObjectAnimator.ofFloat(profileImageView, View.ALPHA, 1, 0))
            .with(ObjectAnimator.ofFloat(clickedImageView, View.SCALE_X, 0, 1))
            .with(ObjectAnimator.ofFloat(clickedImageView, View.SCALE_Y, 0, 1));
    final long animationTransition = 400;
    set.setDuration(animationTransition);
    set.setInterpolator(new DecelerateInterpolator());
    set.addListener(new AnimatorListener() {

        private Drawable clickedDrawable;
        private int[] clickedColors;

        @Override
        public void onAnimationStart(Animator animation) {
            snapshotView.setVisibility(View.VISIBLE);
            snapshotView.setImageBitmap(snapshotBitmap);
            final Drawable profileDrawable = profileImageView.getDrawable();
            clickedDrawable = clickedImageView.getDrawable();
            clickedColors = clickedImageView.getBorderColors();
            final ParcelableAccount oldSelectedAccount = mAccountsAdapter.getSelectedAccount();
            if (oldSelectedAccount == null)
                return;
            mMediaLoader.displayDashboardProfileImage(clickedImageView, oldSelectedAccount, profileDrawable);
            clickedImageView.setBorderColors(profileImageView.getBorderColors());

            displayAccountBanner(account);

            mSwitchAccountAnimationPlaying = true;
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            finishAnimation();
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            finishAnimation();
        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }

        private void finishAnimation() {
            final Editor editor = mPreferences.edit();
            editor.putString(KEY_DEFAULT_ACCOUNT_KEY, account.account_key.toString());
            editor.apply();
            mAccountsAdapter.setSelectedAccount(account);
            updateAccountActions();
            displayCurrentAccount(clickedDrawable);
            snapshotView.setVisibility(View.INVISIBLE);
            snapshotView.setImageDrawable(null);
            profileImageView.setImageDrawable(clickedDrawable);
            profileImageView.setBorderColors(clickedColors);
            profileImageView.setAlpha(1f);
            clickedImageView.setScaleX(1);
            clickedImageView.setScaleY(1);
            clickedImageView.setAlpha(1f);
            mSwitchAccountAnimationPlaying = false;
        }
    });
    set.start();

}

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

private ObjectAnimator getShowToolbarAnimator(View view, float fromValue, float toValue) {
    ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, fromValue, toValue);
    animator.setDuration(cursorToolbarAnimationDuration);
    animator.setStartDelay(getResources().getInteger(R.integer.animation_delay_short));
    animator.setInterpolator(new Expo.EaseOut());
    return animator;
}

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  a va 2 s .  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.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;//from w  w w. j  a  v  a2  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.google.samples.apps.sergio.ui.BaseActivity.java

private void setupAccountBoxToggle() {
    int selfItem = getSelfNavDrawerItem();
    if (mDrawerLayout == null || selfItem == NAVDRAWER_ITEM_INVALID) {
        // this Activity does not have a nav drawer
        return;/*w w w  .j  av  a2  s  . c  o m*/
    }
    mExpandAccountBoxIndicator.setImageResource(mAccountBoxExpanded ? R.drawable.ic_drawer_accounts_collapse
            : R.drawable.ic_drawer_accounts_expand);
    int hideTranslateY = -mAccountListContainer.getHeight() / 4; // last 25% of animation
    if (mAccountBoxExpanded && mAccountListContainer.getTranslationY() == 0) {
        // initial setup
        mAccountListContainer.setAlpha(0);
        mAccountListContainer.setTranslationY(hideTranslateY);
    }

    AnimatorSet set = new AnimatorSet();
    set.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mDrawerItemsListContainer.setVisibility(mAccountBoxExpanded ? View.INVISIBLE : View.VISIBLE);
            mAccountListContainer.setVisibility(mAccountBoxExpanded ? View.VISIBLE : View.INVISIBLE);
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            onAnimationEnd(animation);
        }
    });

    if (mAccountBoxExpanded) {
        mAccountListContainer.setVisibility(View.VISIBLE);
        AnimatorSet subSet = new AnimatorSet();
        subSet.playTogether(
                ObjectAnimator.ofFloat(mAccountListContainer, View.ALPHA, 1)
                        .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION),
                ObjectAnimator.ofFloat(mAccountListContainer, View.TRANSLATION_Y, 0)
                        .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION));
        set.playSequentially(ObjectAnimator.ofFloat(mDrawerItemsListContainer, View.ALPHA, 0)
                .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION), subSet);
        set.start();
    } else {
        mDrawerItemsListContainer.setVisibility(View.VISIBLE);
        AnimatorSet subSet = new AnimatorSet();
        subSet.playTogether(
                ObjectAnimator.ofFloat(mAccountListContainer, View.ALPHA, 0)
                        .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION),
                ObjectAnimator.ofFloat(mAccountListContainer, View.TRANSLATION_Y, hideTranslateY)
                        .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION));
        set.playSequentially(subSet, ObjectAnimator.ofFloat(mDrawerItemsListContainer, View.ALPHA, 1)
                .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION));
        set.start();
    }

    set.start();
}

From source file:com.google.samples.apps.iosched.ui.BaseActivity.java

private void setupAccountBoxToggle() {
    int selfItem = getSelfNavDrawerItem();
    if (mDrawerLayout == null || selfItem == NAVDRAWER_ITEM_INVALID) {
        // this Activity does not have a nav drawer
        return;/*w  w w  .  j  av  a2  s.  com*/
    }
    mExpandAccountBoxIndicator.setImageResource(mAccountBoxExpanded ? R.drawable.ic_navview_accounts_collapse
            : R.drawable.ic_navview_accounts_expand);
    int hideTranslateY = -mAccountListContainer.getHeight() / 4; // last 25% of animation
    if (mAccountBoxExpanded && mAccountListContainer.getTranslationY() == 0) {
        // initial setup
        mAccountListContainer.setAlpha(0);
        mAccountListContainer.setTranslationY(hideTranslateY);
    }

    AnimatorSet set = new AnimatorSet();
    set.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mDrawerItemsListContainer.setVisibility(mAccountBoxExpanded ? View.INVISIBLE : View.VISIBLE);
            mAccountListContainer.setVisibility(mAccountBoxExpanded ? View.VISIBLE : View.INVISIBLE);
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            onAnimationEnd(animation);
        }
    });

    if (mAccountBoxExpanded) {
        mAccountListContainer.setVisibility(View.VISIBLE);
        AnimatorSet subSet = new AnimatorSet();
        subSet.playTogether(
                ObjectAnimator.ofFloat(mAccountListContainer, View.ALPHA, 1)
                        .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION),
                ObjectAnimator.ofFloat(mAccountListContainer, View.TRANSLATION_Y, 0)
                        .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION));
        set.playSequentially(ObjectAnimator.ofFloat(mDrawerItemsListContainer, View.ALPHA, 0)
                .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION), subSet);
        set.start();
    } else {
        mDrawerItemsListContainer.setVisibility(View.VISIBLE);
        AnimatorSet subSet = new AnimatorSet();
        subSet.playTogether(
                ObjectAnimator.ofFloat(mAccountListContainer, View.ALPHA, 0)
                        .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION),
                ObjectAnimator.ofFloat(mAccountListContainer, View.TRANSLATION_Y, hideTranslateY)
                        .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION));
        set.playSequentially(subSet, ObjectAnimator.ofFloat(mDrawerItemsListContainer, View.ALPHA, 1)
                .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION));
        set.start();
    }

    set.start();
}

From source file:com.saarang.samples.apps.iosched.ui.BaseActivity.java

private void setupAccountBoxToggle() {
    int selfItem = getSelfNavDrawerItem();
    if (mDrawerLayout == null || selfItem == NAVDRAWER_ITEM_INVALID) {
        // this Activity does not have a nav drawer
        return;//ww w.  j  a  v  a  2s  . co  m
    }
    mExpandAccountBoxIndicator.setImageResource(
            mAccountBoxExpanded ? com.saarang.samples.apps.iosched.R.drawable.ic_drawer_accounts_collapse
                    : com.saarang.samples.apps.iosched.R.drawable.ic_drawer_accounts_expand);
    int hideTranslateY = -mAccountListContainer.getHeight() / 4; // last 25% of animation
    if (mAccountBoxExpanded && mAccountListContainer.getTranslationY() == 0) {
        // initial setup
        mAccountListContainer.setAlpha(0);
        mAccountListContainer.setTranslationY(hideTranslateY);
    }

    AnimatorSet set = new AnimatorSet();
    set.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mDrawerItemsListContainer.setVisibility(mAccountBoxExpanded ? View.INVISIBLE : View.VISIBLE);
            mAccountListContainer.setVisibility(mAccountBoxExpanded ? View.VISIBLE : View.INVISIBLE);
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            onAnimationEnd(animation);
        }
    });

    if (mAccountBoxExpanded) {
        mAccountListContainer.setVisibility(View.VISIBLE);
        AnimatorSet subSet = new AnimatorSet();
        subSet.playTogether(
                ObjectAnimator.ofFloat(mAccountListContainer, View.ALPHA, 1)
                        .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION),
                ObjectAnimator.ofFloat(mAccountListContainer, View.TRANSLATION_Y, 0)
                        .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION));
        set.playSequentially(ObjectAnimator.ofFloat(mDrawerItemsListContainer, View.ALPHA, 0)
                .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION), subSet);
        set.start();
    } else {
        mDrawerItemsListContainer.setVisibility(View.VISIBLE);
        AnimatorSet subSet = new AnimatorSet();
        subSet.playTogether(
                ObjectAnimator.ofFloat(mAccountListContainer, View.ALPHA, 0)
                        .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION),
                ObjectAnimator.ofFloat(mAccountListContainer, View.TRANSLATION_Y, hideTranslateY)
                        .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION));
        set.playSequentially(subSet, ObjectAnimator.ofFloat(mDrawerItemsListContainer, View.ALPHA, 1)
                .setDuration(ACCOUNT_BOX_EXPAND_ANIM_DURATION));
        set.start();
    }

    set.start();
}