List of usage examples for android.animation AnimatorListenerAdapter AnimatorListenerAdapter
AnimatorListenerAdapter
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// w ww .j ava 2 s . co m 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.android.launcher3.folder.Folder.java
public void animateOpen() { if (!(getParent() instanceof DragLayer)) return;/*from w ww . j av a 2 s. c o m*/ 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.android.nobug.view.pattern.PatternView.java
private void startLineEndAnimation(final CellState state, final float startX, final float startY, final float targetX, final float targetY) { ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, 1); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override/*w w w . j ava 2 s .c o m*/ public void onAnimationUpdate(ValueAnimator animation) { float t = (float) animation.getAnimatedValue(); state.lineEndX = (1 - t) * startX + t * targetX; state.lineEndY = (1 - t) * startY + t * targetY; invalidate(); } }); valueAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { state.lineAnimator = null; } }); valueAnimator.setInterpolator(mFastOutSlowInInterpolator); valueAnimator.setDuration(100); valueAnimator.start(); state.lineAnimator = valueAnimator; }
From source file:com.aliyun.homeshell.Folder.java
public void showSelectApps(int[] pos) { if (mRunningAnimatorSet != null) { if (!mRunningIsShow) { mRunningAnimatorSet.end();/*from w w w .j av a 2 s .c o m*/ } else { return; } } if (mAppsSelectView == null) { mAppsSelectView = (FolderAppsSelectView) LayoutInflater.from(getContext()) .inflate(R.layout.folder_apps_select, null); mAppsSelectView.init(this, mInfo, mLauncher); mLauncher.getDragLayer().addView(mAppsSelectView); } mAppsSelectView.initSelectedState(mInfo); mAppsSelectView.setScaleX(0); mAppsSelectView.setScaleY(0); mAppsSelectView.setPivotX(pos[0]); mAppsSelectView.setPivotY(pos[1]); ObjectAnimator visToInvis = ObjectAnimator.ofFloat(this, "alpha", 1, 0); visToInvis.setDuration(mAnimatorDuration); ObjectAnimator invisToVisX = ObjectAnimator.ofFloat(mAppsSelectView, "scaleX", 0, 1); invisToVisX.setDuration(mAnimatorDuration); ObjectAnimator invisToVisY = ObjectAnimator.ofFloat(mAppsSelectView, "scaleY", 0, 1); invisToVisY.setDuration(mAnimatorDuration); List<Animator> animList = new ArrayList<Animator>(); animList.add(visToInvis); animList.add(invisToVisX); animList.add(invisToVisY); final AnimatorSet as = new AnimatorSet(); as.setInterpolator(new LinearInterpolator()); as.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { mAppsSelectView.setVisibility(View.VISIBLE); mRunningAnimatorSet = as; mRunningIsShow = true; } @Override public void onAnimationEnd(Animator animator) { mRunningAnimatorSet = null; mRunningIsShow = false; Folder.this.setVisibility(View.INVISIBLE); mAppsSelectView.setVisibility(View.VISIBLE); DisplayMetrics metric = new DisplayMetrics(); mLauncher.getWindowManager().getDefaultDisplay().getMetrics(metric); int width = metric.widthPixels; int height = metric.heightPixels; mAppsSelectView.setPivotX(width / 2); mAppsSelectView.setPivotY(height / 2); mAppsSelectView.setFocusableInTouchMode(true); mAppsSelectView.setFocusable(true); mAppsSelectView.requestFocus(); } }); as.playTogether(animList); as.start(); }
From source file:com.btmura.android.reddit.app.AbstractBrowserActivity.java
private AnimatorSet newExpandLeftAnimator() { ObjectAnimator slTransX = ObjectAnimator.ofFloat(leftContainer, "translationX", -leftWidth, 0); ObjectAnimator tlTransX = ObjectAnimator.ofFloat(rightContainer, "translationX", -leftWidth, 0); AnimatorSet as = new AnimatorSet(); as.setDuration(durationMs).play(slTransX).with(tlTransX); as.addListener(new AnimatorListenerAdapter() { @Override//from w ww .j av a2 s . com 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); rightContainer.setLayerType(View.LAYER_TYPE_NONE, null); } }); return as; }
From source file:com.android.tv.menu.MenuLayoutManager.java
/** * Move the current selection to the given {@code position} with animation. * The animation specification is included in http://b/21069476 *//*from www. j ava 2 s. c o m*/ public void setSelectedPositionSmooth(final int position) { if (DEBUG) { Log.d(TAG, "setSelectedPositionSmooth(position=" + position + ") {previousPosition=" + mSelectedPosition + "}"); } if (mMenuView.getVisibility() != View.VISIBLE) { setSelectedPosition(position); return; } if (mSelectedPosition == position) { return; } boolean oldIndexValid = Utils.isIndexValid(mMenuRowViews, mSelectedPosition); SoftPreconditions.checkState(oldIndexValid, TAG, "No previous selection: " + mSelectedPosition); if (!oldIndexValid) { return; } boolean newIndexValid = Utils.isIndexValid(mMenuRowViews, position); SoftPreconditions.checkArgument(newIndexValid, TAG, "position " + position); if (!newIndexValid) { return; } MenuRow row = mMenuRows.get(position); if (!row.isVisible()) { Log.e(TAG, "Moving to the invisible row: " + position); return; } if (mAnimatorSet != null) { // Do not cancel the animation here. The property values should be set to the end values // when the animation finishes. mAnimatorSet.end(); } if (mTitleFadeOutAnimator != null) { // Cancel the animation instead of ending it in order that the title animation starts // again from the intermediate state. mTitleFadeOutAnimator.cancel(); } final int oldPosition = mSelectedPosition; mSelectedPosition = position; if (DEBUG) dumpChildren("startRowAnimation()"); MenuRowView currentView = mMenuRowViews.get(position); // Show the children of the next row. currentView.getTitleView().setVisibility(View.VISIBLE); currentView.getContentsView().setVisibility(View.VISIBLE); // Request focus after the new contents view shows up. mMenuView.requestFocus(); if (mTempTitleViewForOld == null) { // Initialize here because we don't know when the views are inflated. mTempTitleViewForOld = (TextView) mMenuView.findViewById(R.id.temp_title_for_old); mTempTitleViewForCurrent = (TextView) mMenuView.findViewById(R.id.temp_title_for_current); } // Animations. mPropertyValuesAfterAnimation.clear(); List<Animator> animators = new ArrayList<>(); boolean scrollDown = position > oldPosition; List<Rect> layouts = getViewLayouts(mMenuView.getLeft(), mMenuView.getTop(), mMenuView.getRight(), mMenuView.getBottom()); // Old row. MenuRow oldRow = mMenuRows.get(oldPosition); MenuRowView oldView = mMenuRowViews.get(oldPosition); View oldContentsView = oldView.getContentsView(); // Old contents view. animators.add(createAlphaAnimator(oldContentsView, 1.0f, 0.0f, 1.0f, mLinearOutSlowIn) .setDuration(mOldContentsFadeOutDuration)); final TextView oldTitleView = oldView.getTitleView(); setTempTitleView(mTempTitleViewForOld, oldTitleView); Rect oldLayoutRect = layouts.get(oldPosition); if (scrollDown) { // Old title view. if (oldRow.hideTitleWhenSelected() && oldTitleView.getVisibility() != View.VISIBLE) { // This case is not included in the animation specification. mTempTitleViewForOld.setScaleX(1.0f); mTempTitleViewForOld.setScaleY(1.0f); animators.add(createAlphaAnimator(mTempTitleViewForOld, 0.0f, oldView.getTitleViewAlphaDeselected(), mFastOutLinearIn)); int offset = oldLayoutRect.top - mTempTitleViewForOld.getTop(); animators.add(createTranslationYAnimator(mTempTitleViewForOld, offset + mRowScrollUpAnimationOffset, offset)); } else { animators .add(createScaleXAnimator(mTempTitleViewForOld, oldView.getTitleViewScaleSelected(), 1.0f)); animators .add(createScaleYAnimator(mTempTitleViewForOld, oldView.getTitleViewScaleSelected(), 1.0f)); animators.add(createAlphaAnimator(mTempTitleViewForOld, oldTitleView.getAlpha(), oldView.getTitleViewAlphaDeselected(), mLinearOutSlowIn)); animators.add(createTranslationYAnimator(mTempTitleViewForOld, 0, oldLayoutRect.top - mTempTitleViewForOld.getTop())); } oldTitleView.setAlpha(oldView.getTitleViewAlphaDeselected()); oldTitleView.setVisibility(View.INVISIBLE); } else { Rect currentLayoutRect = new Rect(layouts.get(position)); // Old title view. // The move distance in the specification is 32dp(mRowScrollUpAnimationOffset). // But if the height of the upper row is small, the upper row will move down a lot. In // this case, this row needs to move more than the specification to avoid the overlap of // the two titles. // The maximum is to the top of the start position of mTempTitleViewForOld. int distanceCurrentTitle = currentLayoutRect.top - currentView.getTop(); int distance = Math.max(mRowScrollUpAnimationOffset, distanceCurrentTitle); int distanceToTopOfSecondTitle = oldLayoutRect.top - mRowScrollUpAnimationOffset - oldView.getTop(); animators.add( createTranslationYAnimator(oldTitleView, 0.0f, Math.min(distance, distanceToTopOfSecondTitle))); animators.add(createAlphaAnimator(oldTitleView, 1.0f, 0.0f, 1.0f, mLinearOutSlowIn) .setDuration(mOldContentsFadeOutDuration)); animators.add(createScaleXAnimator(oldTitleView, oldView.getTitleViewScaleSelected(), 1.0f)); animators.add(createScaleYAnimator(oldTitleView, oldView.getTitleViewScaleSelected(), 1.0f)); mTempTitleViewForOld.setScaleX(1.0f); mTempTitleViewForOld.setScaleY(1.0f); animators.add(createAlphaAnimator(mTempTitleViewForOld, 0.0f, oldView.getTitleViewAlphaDeselected(), mFastOutLinearIn)); int offset = oldLayoutRect.top - mTempTitleViewForOld.getTop(); animators.add( createTranslationYAnimator(mTempTitleViewForOld, offset - mRowScrollUpAnimationOffset, offset)); } // Current row. Rect currentLayoutRect = new Rect(layouts.get(position)); TextView currentTitleView = currentView.getTitleView(); View currentContentsView = currentView.getContentsView(); currentContentsView.setAlpha(0.0f); if (scrollDown) { // Current title view. setTempTitleView(mTempTitleViewForCurrent, currentTitleView); // The move distance in the specification is 32dp(mRowScrollUpAnimationOffset). // But if the height of the upper row is small, the upper row will move up a lot. In // this case, this row needs to start the move from more than the specification to avoid // the overlap of the two titles. // The maximum is to the top of the end position of mTempTitleViewForCurrent. int distanceOldTitle = oldView.getTop() - oldLayoutRect.top; int distance = Math.max(mRowScrollUpAnimationOffset, distanceOldTitle); int distanceTopOfSecondTitle = currentView.getTop() - mRowScrollUpAnimationOffset - currentLayoutRect.top; animators.add(createTranslationYAnimator(currentTitleView, Math.min(distance, distanceTopOfSecondTitle), 0.0f)); currentView.setTop(currentLayoutRect.top); ObjectAnimator animator = createAlphaAnimator(currentTitleView, 0.0f, 1.0f, mFastOutLinearIn) .setDuration(mCurrentContentsFadeInDuration); animator.setStartDelay(mOldContentsFadeOutDuration); currentTitleView.setAlpha(0.0f); animators.add(animator); animators.add(createScaleXAnimator(currentTitleView, 1.0f, currentView.getTitleViewScaleSelected())); animators.add(createScaleYAnimator(currentTitleView, 1.0f, currentView.getTitleViewScaleSelected())); animators.add(createTranslationYAnimator(mTempTitleViewForCurrent, 0.0f, -mRowScrollUpAnimationOffset)); animators.add(createAlphaAnimator(mTempTitleViewForCurrent, currentView.getTitleViewAlphaDeselected(), 0, mLinearOutSlowIn)); // Current contents view. animators.add(createTranslationYAnimator(currentContentsView, mRowScrollUpAnimationOffset, 0.0f)); animator = createAlphaAnimator(currentContentsView, 0.0f, 1.0f, mFastOutLinearIn) .setDuration(mCurrentContentsFadeInDuration); animator.setStartDelay(mOldContentsFadeOutDuration); animators.add(animator); } else { currentView.setBottom(currentLayoutRect.bottom); // Current title view. int currentViewOffset = currentLayoutRect.top - currentView.getTop(); animators.add(createTranslationYAnimator(currentTitleView, 0, currentViewOffset)); animators.add(createAlphaAnimator(currentTitleView, currentView.getTitleViewAlphaDeselected(), 1.0f, mFastOutSlowIn)); animators.add(createScaleXAnimator(currentTitleView, 1.0f, currentView.getTitleViewScaleSelected())); animators.add(createScaleYAnimator(currentTitleView, 1.0f, currentView.getTitleViewScaleSelected())); // Current contents view. animators.add(createTranslationYAnimator(currentContentsView, currentViewOffset - mRowScrollUpAnimationOffset, currentViewOffset)); ObjectAnimator animator = createAlphaAnimator(currentContentsView, 0.0f, 1.0f, mFastOutLinearIn) .setDuration(mCurrentContentsFadeInDuration); animator.setStartDelay(mOldContentsFadeOutDuration); animators.add(animator); } // Next row. int nextPosition; if (scrollDown) { nextPosition = findNextVisiblePosition(position); if (nextPosition != -1) { MenuRowView nextView = mMenuRowViews.get(nextPosition); Rect nextLayoutRect = layouts.get(nextPosition); animators.add(createTranslationYAnimator(nextView, nextLayoutRect.top + mRowScrollUpAnimationOffset - nextView.getTop(), nextLayoutRect.top - nextView.getTop())); animators.add(createAlphaAnimator(nextView, 0.0f, 1.0f, mFastOutLinearIn)); } } else { nextPosition = findNextVisiblePosition(oldPosition); if (nextPosition != -1) { MenuRowView nextView = mMenuRowViews.get(nextPosition); animators.add(createTranslationYAnimator(nextView, 0, mRowScrollUpAnimationOffset)); animators.add(createAlphaAnimator(nextView, nextView.getTitleViewAlphaDeselected(), 0.0f, 1.0f, mLinearOutSlowIn)); } } // Other rows. int count = mMenuRowViews.size(); for (int i = 0; i < count; ++i) { MenuRowView view = mMenuRowViews.get(i); if (view.getVisibility() == View.VISIBLE && i != oldPosition && i != position && i != nextPosition) { Rect rect = layouts.get(i); animators.add(createTranslationYAnimator(view, 0, rect.top - view.getTop())); } } // Run animation. final List<ViewPropertyValueHolder> propertyValuesAfterAnimation = new ArrayList<>(); propertyValuesAfterAnimation.addAll(mPropertyValuesAfterAnimation); mAnimatorSet = new AnimatorSet(); mAnimatorSet.playTogether(animators); mAnimatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { if (DEBUG) dumpChildren("onRowAnimationEndBefore"); mAnimatorSet = null; // The property values which are different from the end values and need to be // changed after the animation are set here. // e.g. setting translationY to 0, alpha of the contents view to 1. for (ViewPropertyValueHolder holder : propertyValuesAfterAnimation) { holder.property.set(holder.view, holder.value); } oldTitleView.setVisibility(View.VISIBLE); mMenuRowViews.get(oldPosition).onDeselected(); mMenuRowViews.get(position).onSelected(true); mTempTitleViewForOld.setVisibility(View.GONE); mTempTitleViewForCurrent.setVisibility(View.GONE); layout(mMenuView.getLeft(), mMenuView.getTop(), mMenuView.getRight(), mMenuView.getBottom()); if (DEBUG) dumpChildren("onRowAnimationEndAfter"); MenuRow currentRow = mMenuRows.get(position); if (currentRow.hideTitleWhenSelected()) { View titleView = mMenuRowViews.get(position).getTitleView(); mTitleFadeOutAnimator = createAlphaAnimator(titleView, titleView.getAlpha(), 0.0f, mLinearOutSlowIn); mTitleFadeOutAnimator.setStartDelay(TITLE_SHOW_DURATION_BEFORE_HIDDEN_MS); mTitleFadeOutAnimator.addListener(new AnimatorListenerAdapter() { private boolean mCanceled; @Override public void onAnimationCancel(Animator animator) { mCanceled = true; } @Override public void onAnimationEnd(Animator animator) { mTitleFadeOutAnimator = null; if (!mCanceled) { mMenuRowViews.get(position).onSelected(false); } } }); mTitleFadeOutAnimator.start(); } } }); mAnimatorSet.start(); if (DEBUG) dumpChildren("startedRowAnimation()"); }
From source file:com.android.tv.settings.dialog.DialogFragment.java
private void prepareAndAnimateView(final View v, float initTransX, final boolean notifyAnimationFinished) { v.setLayerType(View.LAYER_TYPE_HARDWARE, null); v.buildLayer();// www . j ava2s. c o m v.setAlpha(0); v.setTranslationX(initTransX); v.animate().alpha(1f).translationX(0).setDuration(ANIMATE_IN_DURATION) .setStartDelay(SECONDARY_ANIMATE_DELAY); v.animate().setInterpolator(new DecelerateInterpolator(1.0f)); v.animate().setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { v.setLayerType(View.LAYER_TYPE_NONE, null); if (notifyAnimationFinished) { onIntroAnimationFinished(); } } }); v.animate().start(); }
From source file:com.android.incallui.widget.multiwaveview.GlowPadView.java
private void startWaveAnimation() { mWaveAnimations.cancel();/*from w w w . j a va 2s. com*/ mPointCloud.waveManager.setAlpha(1.0f); mPointCloud.waveManager.setRadius(mHandleDrawable.getWidth() / 2.0f); mWaveAnimations.add(Tweener.to(mPointCloud.waveManager, WAVE_ANIMATION_DURATION, "ease", Ease.Quad.easeOut, "delay", 0, "radius", 2.0f * mOuterRadius, "onUpdate", mUpdateListener, "onComplete", new AnimatorListenerAdapter() { public void onAnimationEnd(Animator animator) { mPointCloud.waveManager.setRadius(0.0f); mPointCloud.waveManager.setAlpha(0.0f); } })); mWaveAnimations.start(); }
From source file:com.android.nobug.view.pattern.PatternView.java
private void startRadiusAnimation(float start, float end, long duration, Interpolator interpolator, final CellState state, final Runnable endRunnable) { ValueAnimator valueAnimator = ValueAnimator.ofFloat(start, end); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override/*ww w. ja va2s. c om*/ public void onAnimationUpdate(ValueAnimator animation) { state.radius = (float) animation.getAnimatedValue(); invalidate(); } }); if (endRunnable != null) { valueAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { endRunnable.run(); } }); } valueAnimator.setInterpolator(interpolator); valueAnimator.setDuration(duration); valueAnimator.start(); }
From source file:com.android.incallui.CallCardFragment.java
/** * Sets the visibility of the secondary caller info box. Note, if the {@code visible} parameter * is passed in {@code true}, and there is no secondary caller info populated (as determined by * {@code mHasSecondaryCallInfo}, the secondary caller info box will not be shown. * * @param visible {@code true} if the secondary caller info should be shown, {@code false} * otherwise.// w w w . j av a 2 s.c o m */ @Override public void setSecondaryInfoVisible(final boolean visible) { boolean wasVisible = mSecondaryCallInfo.isShown(); final boolean isVisible = visible && mHasSecondaryCallInfo; Log.v(this, "setSecondaryInfoVisible: wasVisible = " + wasVisible + " isVisible = " + isVisible); // If visibility didn't change, nothing to do. if (wasVisible == isVisible) { return; } // If we are showing the secondary info, we need to show it before animating so that its // height will be determined on layout. if (isVisible) { mSecondaryCallInfo.setVisibility(View.VISIBLE); } else { mSecondaryCallInfo.setVisibility(View.GONE); } updateFabPositionForSecondaryCallInfo(); // We need to translate the secondary caller info, but we need to know its position after // the layout has occurred so use a {@code ViewTreeObserver}. final ViewTreeObserver observer = getView().getViewTreeObserver(); observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { // We don't want to continue getting called. getView().getViewTreeObserver().removeOnPreDrawListener(this); // Get the height of the secondary call info now, and then re-hide the view prior // to doing the actual animation. int secondaryHeight = mSecondaryCallInfo.getHeight(); if (isVisible) { mSecondaryCallInfo.setVisibility(View.GONE); } else { mSecondaryCallInfo.setVisibility(View.VISIBLE); } Log.v(this, "setSecondaryInfoVisible: secondaryHeight = " + secondaryHeight); // Set the position of the secondary call info card to its starting location. mSecondaryCallInfo.setTranslationY(visible ? secondaryHeight : 0); // Animate the secondary card info slide up/down as it appears and disappears. ViewPropertyAnimator secondaryInfoAnimator = mSecondaryCallInfo.animate() .setInterpolator(AnimUtils.EASE_OUT_EASE_IN).setDuration(mVideoAnimationDuration) .translationY(isVisible ? 0 : secondaryHeight).setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (!isVisible) { mSecondaryCallInfo.setVisibility(View.GONE); } } @Override public void onAnimationStart(Animator animation) { if (isVisible) { mSecondaryCallInfo.setVisibility(View.VISIBLE); } } }); secondaryInfoAnimator.start(); // Notify listeners of a change in the visibility of the secondary info. This is // important when in a video call so that the video call presenter can shift the // video preview up or down to accommodate the secondary caller info. InCallPresenter.getInstance().notifySecondaryCallerInfoVisibilityChanged(visible, secondaryHeight); return true; } }); }