Example usage for android.animation AnimatorSet start

List of usage examples for android.animation AnimatorSet start

Introduction

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

Prototype

@SuppressWarnings("unchecked")
@Override
public void start() 

Source Link

Document

Starting this AnimatorSet will, in turn, start the animations for which it is responsible.

Usage

From source file:org.getlantern.firetweet.fragment.support.AccountsDashboardFragment.java

private void onAccountSelected(AccountProfileImageViewHolder holder, final ParcelableAccount account) {
    if (mSwitchAccountAnimationPlaying)
        return;/*w w  w. j  a v  a 2 s.  c  om*/
    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();
        }

        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;
        }

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

        @Override
        public void onAnimationRepeat(Animator animation) {

        }
    });
    set.start();
}

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

private void onAccountSelected(AccountProfileImageViewHolder holder, final ParcelableAccount account) {
    if (mSwitchAccountAnimationPlaying)
        return;// ww  w .  ja  v  a 2  s  . com
    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.telepatch.ui.ChatActivity.java

public void createMenu(View v, boolean single) {
    if (actionBarLayer.isActionModeShowed()) {
        return;// w  w w .  j a  v a 2s . c  om
    }

    MessageObject message = null;
    if (v instanceof ChatBaseCell) {
        message = ((ChatBaseCell) v).getMessageObject();
    } else if (v instanceof ChatActionCell) {
        message = ((ChatActionCell) v).getMessageObject();
    }
    if (message == null) {
        return;
    }
    final int type = getMessageType(message);

    selectedObject = null;
    forwaringMessage = null;
    selectedMessagesCanCopyIds.clear();
    selectedMessagesIds.clear();

    if (single || type < 2 || type == 6) {
        if (type >= 0) {
            selectedObject = message;
            if (getParentActivity() == null) {
                return;
            }
            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());

            CharSequence[] items = null;

            if (type == 0) {
                items = new CharSequence[] { LocaleController.getString("Retry", R.string.Retry),
                        LocaleController.getString("Delete", R.string.Delete) };
            } else if (type == 1) {
                items = new CharSequence[] { LocaleController.getString("Delete", R.string.Delete) };
            } else if (type == 6) {
                items = new CharSequence[] { LocaleController.getString("Retry", R.string.Retry),
                        LocaleController.getString("Copy", R.string.Copy),
                        LocaleController.getString("Delete", R.string.Delete) };
            } else {
                if (currentEncryptedChat == null) {
                    if (type == 2) {
                        items = new CharSequence[] { LocaleController.getString("Forward", R.string.Forward),
                                LocaleController.getString("Delete", R.string.Delete) };
                    } else if (type == 3) {
                        items = new CharSequence[] { LocaleController.getString("Forward", R.string.Forward),
                                LocaleController.getString("Copy", R.string.Copy),
                                LocaleController.getString("Delete", R.string.Delete) };
                    } else if (type == 4) {
                        items = new CharSequence[] { LocaleController.getString(
                                selectedObject.messageOwner.media instanceof TLRPC.TL_messageMediaDocument
                                        ? "SaveToDownloads"
                                        : "SaveToGallery",
                                selectedObject.messageOwner.media instanceof TLRPC.TL_messageMediaDocument
                                        ? R.string.SaveToDownloads
                                        : R.string.SaveToGallery),
                                LocaleController.getString("Forward", R.string.Forward),
                                LocaleController.getString("Delete", R.string.Delete) };
                    } else if (type == 5) {
                        items = new CharSequence[] {
                                LocaleController.getString("ApplyLocalizationFile",
                                        R.string.ApplyLocalizationFile),
                                LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads),
                                LocaleController.getString("Forward", R.string.Forward),
                                LocaleController.getString("Delete", R.string.Delete) };
                    }
                } else {
                    if (type == 2) {
                        items = new CharSequence[] { LocaleController.getString("Delete", R.string.Delete) };
                    } else if (type == 3) {
                        items = new CharSequence[] { LocaleController.getString("Copy", R.string.Copy),
                                LocaleController.getString("Delete", R.string.Delete) };
                    } else if (type == 4) {
                        items = new CharSequence[] { LocaleController.getString(
                                selectedObject.messageOwner.media instanceof TLRPC.TL_messageMediaDocument
                                        ? "SaveToDownloads"
                                        : "SaveToGallery",
                                selectedObject.messageOwner.media instanceof TLRPC.TL_messageMediaDocument
                                        ? R.string.SaveToDownloads
                                        : R.string.SaveToGallery),
                                LocaleController.getString("Delete", R.string.Delete) };
                    } else if (type == 5) {
                        items = new CharSequence[] {
                                LocaleController.getString("ApplyLocalizationFile",
                                        R.string.ApplyLocalizationFile),
                                LocaleController.getString("Delete", R.string.Delete) };
                    }
                }
            }

            builder.setItems(items, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    if (selectedObject == null) {
                        return;
                    }
                    if (type == 0) {
                        if (i == 0) {
                            processSelectedOption(0);
                        } else if (i == 1) {
                            processSelectedOption(1);
                        }
                    } else if (type == 1) {
                        processSelectedOption(1);
                    } else if (type == 2) {
                        if (currentEncryptedChat == null) {
                            if (i == 0) {
                                processSelectedOption(2);
                            } else if (i == 1) {
                                processSelectedOption(1);
                            }
                        } else {
                            processSelectedOption(1);
                        }
                    } else if (type == 3) {
                        if (currentEncryptedChat == null) {
                            if (i == 0) {
                                processSelectedOption(2);
                            } else if (i == 1) {
                                processSelectedOption(3);
                            } else if (i == 2) {
                                processSelectedOption(1);
                            }
                        } else {
                            if (i == 0) {
                                processSelectedOption(3);
                            } else if (i == 1) {
                                processSelectedOption(1);
                            }
                        }
                    } else if (type == 4) {
                        if (currentEncryptedChat == null) {
                            if (i == 0) {
                                processSelectedOption(4);
                            } else if (i == 1) {
                                processSelectedOption(2);
                            } else if (i == 2) {
                                processSelectedOption(1);
                            }
                        } else {
                            if (i == 0) {

                            } else if (i == 1) {
                                processSelectedOption(1);
                            }
                        }
                    } else if (type == 5) {
                        if (i == 0) {
                            processSelectedOption(5);
                        } else {
                            if (currentEncryptedChat == null) {
                                if (i == 1) {
                                    processSelectedOption(4);
                                } else if (i == 2) {
                                    processSelectedOption(2);
                                } else if (i == 3) {
                                    processSelectedOption(1);
                                }
                            } else {
                                if (i == 1) {
                                    processSelectedOption(1);
                                }
                            }
                        }
                    } else if (type == 6) {
                        if (i == 0) {
                            processSelectedOption(0);
                        } else if (i == 1) {
                            processSelectedOption(3);
                        } else if (i == 2) {
                            processSelectedOption(1);
                        }
                    }
                }
            });

            builder.setTitle(LocaleController.getString("Message", R.string.Message));
            showAlertDialog(builder);
        }
        return;
    }
    actionBarLayer.showActionMode();
    if (Build.VERSION.SDK_INT >= 11) {
        AnimatorSet animatorSet = new AnimatorSet();
        ArrayList<Animator> animators = new ArrayList<Animator>();
        for (int a = 0; a < actionModeViews.size(); a++) {
            View view = actionModeViews.get(a);
            if (a < 2) {
                animators.add(ObjectAnimator.ofFloat(view, "translationX", -AndroidUtilities.dp(56), 0));
            } else {
                animators.add(ObjectAnimator.ofFloat(view, "scaleY", 0.1f, 1.0f));
            }
        }
        animatorSet.playTogether(animators);
        animatorSet.setDuration(250);
        animatorSet.start();
    }
    addToSelectedMessages(message);
    updateActionModeTitle();
    updateVisibleRows();
}

From source file:com.aliyun.homeshell.Folder.java

public void backFromSelectApps() {
    if (mRunningAnimatorSet != null) {
        if (mRunningIsShow) {
            mRunningAnimatorSet.end();/*from w w  w . j a v a  2 s. c o  m*/
        } else {
            return;
        }
    }
    ObjectAnimator invisToVis = ObjectAnimator.ofFloat(this, "alpha", 0, 1);
    invisToVis.setDuration(mAnimatorDuration);
    ObjectAnimator visToInvisX = ObjectAnimator.ofFloat(mAppsSelectView, "scaleX", 1, 0);
    visToInvisX.setDuration(mAnimatorDuration);
    ObjectAnimator visToInvisY = ObjectAnimator.ofFloat(mAppsSelectView, "scaleY", 1, 0);
    visToInvisY.setDuration(mAnimatorDuration);
    List<Animator> animList = new ArrayList<Animator>();
    animList.add(invisToVis);
    animList.add(visToInvisX);
    animList.add(visToInvisY);
    final AnimatorSet as = new AnimatorSet();
    as.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animator) {
            Folder.this.setVisibility(View.VISIBLE);
            mRunningAnimatorSet = as;
            mRunningIsShow = false;
            /*YUNOS BEGIN*/
            //##date:2014/06/27 ##author:yangshan.ys@alibaba-inc.com##BugID:132255
            //when back to folder from folderappsselectview ,prevent the mFolderName from getting focus 
            mFolderName.setFocusable(false);
            /* YUNOS END */
        }

        @Override
        public void onAnimationEnd(Animator animator) {
            mRunningAnimatorSet = null;
            mRunningIsShow = false;
            mAppsSelectView.setVisibility(View.INVISIBLE);
            Folder.this.setVisibility(View.VISIBLE);
            /*YUNOS BEGIN*/
            //##date:2014/06/27 ##author:yangshan.ys@alibaba-inc.com##BugID:132255
            //when back to folder from folderappsselectview ,prevent the mFolderName from getting focus 
            mFolderName.setFocusable(true);
            /*YUNOS BEGIN*/
            //##date:2014/06/27 ##author:yangshan.ys@alibaba-inc.com##BugID:133680
            //when back to folder from folderappsselectview, the folderName cannot be changed
            mFolderName.setFocusableInTouchMode(true);
            /* YUNOS END */
            /* YUNOS END */
            mIsEditingName = false;
        }
    });
    as.playTogether(animList);
    as.start();
}

From source file:app.umitems.greenclock.widget.sgv.StaggeredGridView.java

/**
 * Performs layout animation of child views.
 * @throws IllegalStateException Exception is thrown of currently set animation mode is
 * not recognized.// w w w.ja  v a 2 s  .c om
 */
private void handleLayoutAnimation() throws IllegalStateException {
    final List<Animator> animators = new ArrayList<Animator>();

    // b/8422632 - Without this dummy first animator, startDelays of subsequent animators won't
    // be honored correctly; all animators will block regardless of startDelay until the first
    // animator in the AnimatorSet truly starts playing.
    final ValueAnimator anim = ValueAnimator.ofFloat(0f, 1f);
    anim.setDuration(0);
    animators.add(anim);

    addOutAnimatorsForStaleViews(animators, mAnimationOutMode);

    // Play the In animators at a slight delay after all Out animators have started.
    final int animationInStartDelay = animators.size() > 0
            ? (SgvAnimationHelper.getDefaultAnimationDuration() / 2)
            : 0;
    addInAnimators(animators, mAnimationInMode, animationInStartDelay);

    if (animators != null && animators.size() > 0) {
        final AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(animators);
        animatorSet.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationStart(Animator animation) {
                mIsCurrentAnimationCanceled = false;
                mCurrentRunningAnimatorSet = animatorSet;
            }

            @Override
            public void onAnimationCancel(Animator animation) {
                mIsCurrentAnimationCanceled = true;
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                if (!mIsCurrentAnimationCanceled) {
                    // If this animation ended naturally, not because it was canceled, then
                    // reset the animation mode back to ANIMATION_MODE_NONE.  However, if
                    // the animation was canceled by a data change, then keep the mode as is,
                    // so that on a re-layout, we can resume animation from the views' current
                    // positions.
                    resetAnimationMode();
                }
                mCurrentRunningAnimatorSet = null;
            }
        });

        Log.v(TAG, "starting");
        animatorSet.start();
    } else {
        resetAnimationMode();
    }

    mViewsToAnimateOut.clear();
    mChildRectsForAnimation.clear();
}

From source file:se.oort.clockify.widget.sgv.StaggeredGridView.java

/**
 * Performs layout animation of child views.
 * @throws IllegalStateException Exception is thrown of currently set animation mode is
 * not recognized./*from   w w  w .ja  v a  2  s .c o  m*/
 */
private void handleLayoutAnimation() throws IllegalStateException {
    final List<Animator> animators = new ArrayList<Animator>();

    // b/8422632 - Without this dummy first animator, startDelays of subsequent animators won't
    // be honored correctly; all animators will block regardless of startDelay until the first
    // animator in the AnimatorSet truly starts playing.
    final ValueAnimator anim = ValueAnimator.ofFloat(0f, 1f);
    anim.setDuration(0);
    animators.add(anim);

    addOutAnimatorsForStaleViews(animators, mAnimationOutMode);

    // Play the In animators at a slight delay after all Out animators have started.
    final int animationInStartDelay = animators.size() > 0
            ? (SgvAnimationHelper.getDefaultAnimationDuration() / 2)
            : 0;
    addInAnimators(animators, mAnimationInMode, animationInStartDelay);

    if (animators != null && animators.size() > 0) {
        final AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(animators);
        animatorSet.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationStart(Animator animation) {
                mIsCurrentAnimationCanceled = false;
                mCurrentRunningAnimatorSet = animatorSet;
            }

            @Override
            public void onAnimationCancel(Animator animation) {
                mIsCurrentAnimationCanceled = true;
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                if (!mIsCurrentAnimationCanceled) {
                    // If this animation ended naturally, not because it was canceled, then
                    // reset the animation mode back to ANIMATION_MODE_NONE.  However, if
                    // the animation was canceled by a data change, then keep the mode as is,
                    // so that on a re-layout, we can resume animation from the views' current
                    // positions.
                    resetAnimationMode();
                }
                mCurrentRunningAnimatorSet = null;
            }
        });

        Log.v(LOG_TAG, "starting");
        animatorSet.start();
    } else {
        resetAnimationMode();
    }

    mViewsToAnimateOut.clear();
    mChildRectsForAnimation.clear();
}

From source file:kr.wdream.ui.PhotoViewer.java

private void toggleCheckImageView(boolean show) {
    AnimatorSet animatorSet = new AnimatorSet();
    ArrayList<Animator> arrayList = new ArrayList<>();
    arrayList.add(ObjectAnimator.ofFloat(pickerView, "alpha", show ? 1.0f : 0.0f));
    if (needCaptionLayout) {
        arrayList.add(ObjectAnimator.ofFloat(captionTextView, "alpha", show ? 1.0f : 0.0f));
    }/*from w  w  w .  j a va  2s  . c om*/
    if (sendPhotoType == 0) {
        arrayList.add(ObjectAnimator.ofFloat(checkImageView, "alpha", show ? 1.0f : 0.0f));
    }
    animatorSet.playTogether(arrayList);
    animatorSet.setDuration(200);
    animatorSet.start();
}

From source file:com.android.launcher2.Launcher.java

/**
 * Runs a new animation that scales up icons that were added while Launcher was in the
 * background.//from ww w.  jav  a  2 s . com
 *
 * @param immediate whether to run the animation or show the results immediately
 */
private void runNewAppsAnimation(boolean immediate) {
    AnimatorSet anim = LauncherAnimUtils.createAnimatorSet();
    Collection<Animator> bounceAnims = new ArrayList<Animator>();

    // Order these new views spatially so that they animate in order
    Collections.sort(mNewShortcutAnimateViews, new Comparator<View>() {
        @Override
        public int compare(View a, View b) {
            CellLayout.LayoutParams alp = (CellLayout.LayoutParams) a.getLayoutParams();
            CellLayout.LayoutParams blp = (CellLayout.LayoutParams) b.getLayoutParams();
            int cellCountX = LauncherModel.getCellCountX();
            return (alp.cellY * cellCountX + alp.cellX) - (blp.cellY * cellCountX + blp.cellX);
        }
    });

    // Animate each of the views in place (or show them immediately if requested)
    if (immediate) {
        for (View v : mNewShortcutAnimateViews) {
            v.setAlpha(1f);
            v.setScaleX(1f);
            v.setScaleY(1f);
        }
    } else {
        for (int i = 0; i < mNewShortcutAnimateViews.size(); ++i) {
            View v = mNewShortcutAnimateViews.get(i);
            ValueAnimator bounceAnim = LauncherAnimUtils.ofPropertyValuesHolder(v,
                    PropertyValuesHolder.ofFloat("alpha", 1f), PropertyValuesHolder.ofFloat("scaleX", 1f),
                    PropertyValuesHolder.ofFloat("scaleY", 1f));
            bounceAnim.setDuration(InstallShortcutReceiver.NEW_SHORTCUT_BOUNCE_DURATION);
            bounceAnim.setStartDelay(i * InstallShortcutReceiver.NEW_SHORTCUT_STAGGER_DELAY);
            bounceAnim.setInterpolator(new SmoothPagedView.OvershootInterpolator());
            bounceAnims.add(bounceAnim);
        }
        anim.playTogether(bounceAnims);
        anim.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                if (mWorkspace != null) {
                    mWorkspace.postDelayed(mBuildLayersRunnable, 500);
                }
            }
        });
        anim.start();
    }

    // Clean up
    mNewShortcutAnimatePage = -1;
    mNewShortcutAnimateViews.clear();
    new Thread("clearNewAppsThread") {
        public void run() {
            mSharedPrefs.edit().putInt(InstallShortcutReceiver.NEW_APPS_PAGE_KEY, -1)
                    .putStringSet(InstallShortcutReceiver.NEW_APPS_LIST_KEY, null).commit();
        }
    }.start();
}

From source file:org.telegram.ui.ArticleViewer.java

private void showActionBar(int delay) {
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(ObjectAnimator.ofFloat(backButton, "alpha", 1.0f),
            ObjectAnimator.ofFloat(shareContainer, "alpha", 1.0f));
    animatorSet.setDuration(150);//w w  w  .  ja  v a  2s  .  c  o m
    animatorSet.setStartDelay(delay);
    animatorSet.start();
}

From source file:org.telegram.ui.ArticleViewer.java

private void hideActionBar() {
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(ObjectAnimator.ofFloat(backButton, "alpha", 0.0f),
            ObjectAnimator.ofFloat(shareContainer, "alpha", 0.0f));
    animatorSet.setDuration(250);//from  w  w  w.  ja  v a2  s.com
    animatorSet.setInterpolator(new DecelerateInterpolator());
    animatorSet.start();
}