private Animator createHideItemAnimator(final View item) { final float dx = centerItem.getX() - item.getX(); final float dy = centerItem.getY() - item.getY(); Animator anim = ObjectAnimator.ofPropertyValuesHolder( item, AnimatorUtils.scaleX(1f, 0f), AnimatorUtils.scaleY(1f, 0f), AnimatorUtils.translationX(0f, dx), AnimatorUtils.translationY(0f, dy) ); anim.setInterpolator(new DecelerateInterpolator()); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); item.setTranslationX(0f); item.setTranslationY(0f); } }); anim.setDuration(50); return anim; }
/** */ @Override void hideProgressBar(SearchView searchView) { final CircularProgressBar progressBar = searchView.mProgressBar; final ViewPropertyAnimator progressBarAnimator = progressBar.animate(); progressBarAnimator.setListener(null); progressBarAnimator.cancel(); progressBarAnimator .alpha(0.0f) .setDuration(UiConfig.ANIMATION_DURATION_SHORT) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { progressBar.setVisibility(View.INVISIBLE); } }) .start(); final View icon = searchView.mButtonIcon; final ViewPropertyAnimator iconAnimator = icon.animate(); iconAnimator.setListener(null); iconAnimator.cancel(); icon.setVisibility(View.VISIBLE); icon.setScaleX(0.5f); icon.setScaleY(0.5f); icon.setAlpha(0.0f); iconAnimator .scaleX(1.0f) .scaleY(1.0f) .alpha(1.0f) .setDuration(UiConfig.ANIMATION_DURATION_SHORT) .setInterpolator(iconInterpolator) .setListener(null) .start(); }
@Override public RefreshKernel startTwoLevel(boolean open) { if (open) { AnimatorListenerAdapter listener = new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { SmartRefreshLayout.this.notifyStateChanged(RefreshState.TwoLevel); } }; ValueAnimator animator = SmartRefreshLayout.this.animSpinner(SmartRefreshLayout.this.getMeasuredHeight()); if (animator != null && animator == SmartRefreshLayout.this.reboundAnimator) { animator.setDuration(SmartRefreshLayout.this.mFloorDuration); animator.addListener(listener); } else { listener.onAnimationEnd(null); } } else { if (animSpinner(0) == null) { SmartRefreshLayout.this.notifyStateChanged(RefreshState.None); } } return this; }
private void doStart(long delay) { ObjectAnimator topMaskAnimator = ObjectAnimator.ofFloat(topMaskView, "translationY", topMaskView.getTranslationY(), -halfHitBlockHeight); ObjectAnimator bottomMaskAnimator = ObjectAnimator.ofFloat(bottomMaskView, "translationY", bottomMaskView.getTranslationY(), halfHitBlockHeight); ObjectAnimator maskShadowAnimator = ObjectAnimator.ofFloat(maskReLayout, "alpha", maskReLayout.getAlpha(), 0); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(topMaskAnimator).with(bottomMaskAnimator).with(maskShadowAnimator); animatorSet.setDuration(800); animatorSet.setStartDelay(delay); animatorSet.start(); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { topMaskView.setVisibility(View.GONE); bottomMaskView.setVisibility(View.GONE); maskReLayout.setVisibility(View.GONE); onGameStart(); } }); }
private void toolbarAnimateHide() { if (mIsActionBarVisible) { mCommonToolbar.animate() .translationY(-mCommonToolbar.getHeight()) .setInterpolator(new LinearInterpolator()) .setDuration(180) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { toolbarSetElevation(0); hideStatusBar(); if (mTocListPopupWindow != null && mTocListPopupWindow.isShowing()) { mTocListPopupWindow.dismiss(); } } }); mIsActionBarVisible = false; } }
private void reset() { //Animate mobile view back to original position final View view = getViewByPosition(mobileViewCurrentPos); if (view != null && mobileView != null) { float y = getViewRawCoords(view)[1]; mobileView.animate().y(y).setDuration(MOVE_DURATION).setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { view.setVisibility(View.VISIBLE); if (mobileView != null) { ViewGroup parent = (ViewGroup) mobileView.getParent(); parent.removeView(mobileView); mobileView = null; } } }); } dragging = false; mobileViewStartY = -1; mobileViewCurrentPos = -1; }
public void loadMore() { if (mPullLoadMoreListener != null && hasMore) { mFooterView.animate() .translationY(0) .setDuration(300) .setInterpolator(new AccelerateDecelerateInterpolator()) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { mprogressBar.setVisibility(View.VISIBLE); loadMoreText.setText(mContext.getString(R.string.load_more_text)); mFooterView.setVisibility(View.VISIBLE); } }) .start(); invalidate(); mPullLoadMoreListener.onLoadMore(); } }
private void animateRevealHide(final View viewRoot) { int cx = (viewRoot.getLeft() + viewRoot.getRight()) / 2; int cy = (viewRoot.getTop() + viewRoot.getBottom()) / 2; int initialRadius = viewRoot.getWidth(); Animator anim = ViewAnimationUtils.createCircularReveal(viewRoot, cx, cy, initialRadius, 0); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); viewRoot.setVisibility(View.INVISIBLE); } }); anim.setDuration(getResources().getInteger(R.integer.anim_duration_medium)); anim.start(); }
private void showSharePicker() { final boolean hasSubView = presentView != null; if (hasSubView) { final View focusedChild = ShareView.this.getFocusedChild(); UiUtils.hideKeyBoard(focusedChild); final Animator appearAnimator = animatorFactory.createDisappearAnimator(presentView); appearAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { removeSubViews(); sharePickerView.setVisibility(VISIBLE); } }); appearAnimator.start(); } shareContext = null; }
@Override public void showContent() { if (adapter.getItemCount() == 0) { if (isRestoringViewState()) { emptyView.setVisibility(View.VISIBLE); } else { ObjectAnimator anim = ObjectAnimator.ofFloat(emptyView, "alpha", 0f, 1f).setDuration(300); anim.setStartDelay(250); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { emptyView.setVisibility(View.VISIBLE); } }); anim.start(); } } else { emptyView.setVisibility(View.GONE); } super.showContent(); }
private void animateDragViewToOriginalPosition() { if (mDragView != null) { Animator anim = new LauncherViewPropertyAnimator(mDragView) .translationX(0) .translationY(0) .scaleX(1) .scaleY(1) .setDuration(REORDERING_DROP_REPOSITION_DURATION); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { onPostReorderingAnimationCompleted(); } }); anim.start(); } }
private void unRevealActivity(final View revealView, int endCenterX, int endCenterY) { int startCenterX = revealView.getWidth() / 2; int startCenterY = revealView.getHeight() / 2; float startRadius = Math.max(revealView.getWidth(), revealView.getHeight()) * 1.1f; float finalRadius = 0; Animator circularReveal = ViewAnimationCompatUtils.createCircularReveal(revealView, startCenterX, startCenterY, startRadius, endCenterX, endCenterY, finalRadius); circularReveal.setDuration(500); circularReveal.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { revealView.setVisibility(View.INVISIBLE); finish(); } }); circularReveal.start(); }
private ValueAnimator createExpandValueAnimator() { ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f); animator.setDuration(DEFAULT_ANIMATION_DURATION_EXPAND); animator.setInterpolator(new AccelerateInterpolator()); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { mExpandedScaleFactor[0] = (float) valueAnimator.getAnimatedValue(); invalidateSelf(); } }); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { notifyExpanded(); } }); return animator; }
private void animateDragViewToOriginalPosition() { if (mDragView != null) { Animator anim = LauncherAnimUtils.ofPropertyValuesHolder(mDragView, new PropertyListBuilder() .scale(1) .translationX(0) .translationY(0) .build()) .setDuration(REORDERING_DROP_REPOSITION_DURATION); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { onPostReorderingAnimationCompleted(); } }); anim.start(); } }
private void snapChild(final View animView, final float targetLeft, float velocity) { final boolean canBeDismissed = mCallback.canChildBeDismissed(animView); AnimatorUpdateListener updateListener = new AnimatorUpdateListener() { public void onAnimationUpdate(ValueAnimator animation) { onTranslationUpdate(animView, (float) animation.getAnimatedValue(), canBeDismissed); } }; Animator anim = getViewTranslationAnimator(animView, targetLeft, updateListener); if (anim == null) { return; } int duration = SNAP_ANIM_LEN; anim.setDuration(duration); anim.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator animator) { mSnappingChild = false; updateSwipeProgressFromOffset(animView, canBeDismissed); mCallback.onChildSnappedBack(animView, targetLeft); } }); prepareSnapBackAnimation(animView, anim); mSnappingChild = true; anim.start(); }
@Override public SkinAnimator apply(@NonNull final View view, @Nullable final Action action) { animator = ObjectAnimator.ofPropertyValuesHolder(view, PropertyValuesHolder.ofFloat("alpha", 1, 0), PropertyValuesHolder.ofFloat("translationX", view.getLeft(), view.getRight())); animator.setDuration(3 * PRE_DURATION); animator.setInterpolator(new AnticipateInterpolator()); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); resetView(view); if (action != null) { action.action(); } } }); return this; }
private void open(boolean animate) { if (mIsOpen || mOpenCloseAnimator.isRunning()) { return; } mIsOpen = true; setLightNavBar(true); if (animate) { mOpenCloseAnimator.setValues(new PropertyListBuilder() .translationY(mTranslationYOpen).build()); mOpenCloseAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mVerticalPullDetector.finishedScrolling(); } }); mOpenCloseAnimator.setInterpolator(mFastOutSlowInInterpolator); mOpenCloseAnimator.start(); } else { setTranslationY(mTranslationYOpen); } }
private void fadeOut() { contentView.setAlpha(0f); contentView.setVisibility(View.VISIBLE); contentView.animate() .alpha(1f) .setDuration(getResources().getInteger( android.R.integer.config_longAnimTime)) .setListener(null); loadingView.animate() .alpha(0f) .setDuration(getResources().getInteger( android.R.integer.config_longAnimTime)) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { loadingView.setVisibility(View.GONE); } }); }
public void hide() { post(new Runnable() { @Override public void run() { ObjectAnimator objectAnimator = ObjectAnimator.ofInt(ShareCard.this, "height", 0); objectAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); setVisibility(GONE); if (mListener != null) { mListener.onClick(ShareCard.this); } } }); objectAnimator.setDuration(500); objectAnimator.setInterpolator(new AnticipateInterpolator()); objectAnimator.setRepeatCount(0); objectAnimator.start(); } }); }
private ObjectAnimator createExitTabSwitcherAnimation( final boolean animateNormalToolbar) { ObjectAnimator exitAnimation = ObjectAnimator.ofFloat(this, mTabSwitcherModePercentProperty, 0.f); exitAnimation.setDuration(animateNormalToolbar ? TAB_SWITCHER_MODE_EXIT_NORMAL_ANIMATION_DURATION_MS : TAB_SWITCHER_MODE_EXIT_FADE_ANIMATION_DURATION_MS); exitAnimation.setInterpolator(new LinearInterpolator()); exitAnimation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { updateViewsForTabSwitcherMode(); } }); return exitAnimation; }
private void reset() { if (this.mAnimator == null || !this.mAnimator.isRunning()) { this.mAnimator = ObjectAnimator.ofInt(this, "t", new int[]{((int) (-this.distance)) / 4, 0}); this.mAnimator.setDuration(150); this.mAnimator.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); PullToZoomScrollView.this.isPreparePull = false; if (PullToZoomScrollView.this.distance / aj.hA > ((float) PullToZoomScrollView.this.DEFAULT_PULL_HEIGHT)) { if (PullToZoomScrollView.this.onPullToZoomListener != null) { PullToZoomScrollView.this.onPullToZoomListener.onPull(); } } else if (PullToZoomScrollView.this.onPullToZoomListener != null) { PullToZoomScrollView.this.onPullToZoomListener.onCancelPull(); } } }); this.mAnimator.start(); } }
/** * Conceal the view from the given centerX and centerY. * * @param view the target view. * @param duration animation duration. * @param centerX the pivotX * @param centerY the pivotY * @param startRadius the radius of the end of the animation, which is generally the maximum of the view's height and width. * @param endRadius the radius of the beginning of the animation, which is generally zero. */ private static void conceal(final View view, final int duration, final int centerX, final int centerY, final float startRadius, final float endRadius) { versionCheck(new Runnable() { @Override public void run() { Animator animator = ViewAnimationUtils.createCircularReveal(view, centerX, centerY, startRadius, endRadius); animator.setDuration(duration); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { view.setVisibility(View.GONE); } }); animator.start(); } }, REVEAL_WARNING); }
/** * Creates and returns an animation listener, which allows to zoom in the currently selected * tab, when a peek animation has been ended. * * @param selectedItem * The item, which corresponds to the currently selected tab, as an instance of the * class {@link AbstractItem}. The item may not be null * @param peekAnimation * The peek animation as an instance of the class {@link PeekAnimation}. The peek * animation may not be null * @return The listener, which has been created, as an instance of the type {@link * AnimatorListener}. The listener may not be null */ @NonNull private AnimatorListener createZoomOutAnimationListener( @NonNull final AbstractItem selectedItem, @NonNull final PeekAnimation peekAnimation) { return new AnimatorListenerAdapter() { @Override public void onAnimationEnd(final Animator animation) { super.onAnimationEnd(animation); getModel().removeListener(PhoneTabSwitcherLayout.this); getModel().hideSwitcher(); long totalDuration = peekAnimation.getDuration() != -1 ? peekAnimation.getDuration() : peekAnimationDuration; long duration = totalDuration / 3; Interpolator interpolator = peekAnimation.getInterpolator() != null ? peekAnimation.getInterpolator() : new AccelerateDecelerateInterpolator(); animateHideSwitcher(selectedItem, duration, interpolator, duration, createZoomInAnimationListener(selectedItem)); } }; }
private void releaseView() { final Interpolator interpolator = new OvershootInterpolator(); final int duration = 700; for (int i = 0; i < mChildCount; i++) { final View child_i = mChildren.get(i); final int delay = mDragDelay * (mChildCount - 1 - i); child_i.postDelayed(new Runnable() { @Override public void run() { child_i.animate() .translationX(mTargetLocation[0]) .translationY(mTargetLocation[1]) .setDuration(duration) .setInterpolator(interpolator) .start(); } }, delay); } mChildren.get(0).animate().setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { // when all animators finish, release the shield view mShieldView.setVisibility(View.GONE); } }); }
@UiThread private void onLoadPokemonFinish() { mBtnPokeDict.setEnabled(true); mBtnPokeQuiz.setEnabled(true); mTvIntro.postDelayed(() -> mTvIntro.animate() .scaleX(1.f) .scaleY(1.f) .alpha(1.0f) .setDuration(500) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); mBtnPokeDict.animate() .alpha(1.0f) .setDuration(1000) .start(); mBtnPokeQuiz.animate() .alpha(1.0f) .setDuration(1000) .start(); } }).start(), 500); }
/** * Creates and returns an animation listener, which allows to zoom in the currently selected * tab, when a peek animation has been ended. * * @param selectedTabItem * The tab item, which corresponds to the currently selected tab, as an instance of the * class {@link TabItem}. The tab item may not be null * @param peekAnimation * The peek animation as an instance of the class {@link PeekAnimation}. The peek * animation may not be null * @return The listener, which has been created, as an instance of the type {@link * AnimatorListener}. The listener may not be null */ @NonNull private AnimatorListener createZoomOutAnimationListener(@NonNull final TabItem selectedTabItem, @NonNull final PeekAnimation peekAnimation) { return new AnimatorListenerAdapter() { @Override public void onAnimationEnd(final Animator animation) { super.onAnimationEnd(animation); getModel().removeListener(PhoneTabSwitcherLayout.this); getModel().hideSwitcher(); long totalDuration = peekAnimation.getDuration() != -1 ? peekAnimation.getDuration() : peekAnimationDuration; long duration = totalDuration / 3; Interpolator interpolator = peekAnimation.getInterpolator() != null ? peekAnimation.getInterpolator() : new AccelerateDecelerateInterpolator(); animateHideSwitcher(selectedTabItem, duration, interpolator, duration, createZoomInAnimationListener(selectedTabItem)); } }; }
public void startMergeAnimation() { if(mCancelAnimator != null&&mCancelAnimator.isRunning()){ mCancelAnimator.cancel(); } if(mStarAnimator == null) { mStarAnimator = ObjectAnimator.ofInt(this, mOutlineProperty, 0); mStarAnimator.setDuration(mAnimationDuration); mStarAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { inMerge = true; } }); }else if(mStarAnimator.isRunning()){ mStarAnimator.cancel(); } mStarAnimator.start(); }
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private ObjectAnimator createBaseWobble(final View v) { if (!isPreLollipop()) v.setLayerType(LAYER_TYPE_SOFTWARE, null); ObjectAnimator animator = new ObjectAnimator(); animator.setDuration(180); animator.setRepeatMode(ValueAnimator.REVERSE); animator.setRepeatCount(ValueAnimator.INFINITE); animator.setPropertyName("rotation"); animator.setTarget(v); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { v.setLayerType(LAYER_TYPE_NONE, null); } }); return animator; }
public void addRow(View view) { mButton.setEnabled(false); mItemNum++; ListItemObject obj = mValues[mItemNum % mValues.length]; final ListItemObject newObj = new ListItemObject(obj.getTitle(), obj.getImgResource(), mCellHeight); boolean shouldAnimateInNewImage = mListView.shouldAnimateInNewImage(); if (!shouldAnimateInNewImage) { mListView.addRow(newObj); return; } mListView.setEnabled(false); ObjectAnimator animator = mRoundView.getScalingAnimator(); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationRepeat(Animator animation) { mListView.addRow(newObj); } }); animator.start(); }
@Override public void onBackPressed() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { finishAfterTransition(); } else { mShareElement.convert(mImageView) .setDuration(ANIMATOR_DURATION) .setInterpolator(new LinearInterpolator()) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { finish(); overridePendingTransition(0, 0); } }) .startExitAnimator(); } }
@SuppressWarnings("NewApi") private void hideMenu() { List<Animator> animList = new ArrayList<>(); for (int i = arcLayout.getChildCount() - 1; i >= 0; i--) { animList.add(createHideItemAnimator(arcLayout.getChildAt(i))); } AnimatorSet animSet = new AnimatorSet(); animSet.setDuration(400); animSet.setInterpolator(new AnticipateInterpolator()); animSet.playTogether(animList); animSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); menuLayout.setVisibility(View.INVISIBLE); } }); animSet.start(); }
public static void startAnimators(final View view, int startOffsetX, int startOffsetY, long delay) { if (view.getVisibility() == View.VISIBLE && view.getAlpha() != 0f) { view.clearAnimation(); view.animate().cancel(); final Resources res = view.getResources(); final float endAlpha = view.getAlpha(); final float endTranslateX = view.getTranslationX(); final float endTranslateY = view.getTranslationY(); view.setAlpha(0); final Animator fade = ObjectAnimator.ofFloat(view, View.ALPHA, endAlpha); fade.setDuration(res.getInteger(R.integer.material_in_fade_anim_duration)); fade.setInterpolator(new AccelerateInterpolator()); fade.setStartDelay(delay); fade.start(); ViewPropertyAnimator slide = view.animate(); if (startOffsetY != 0) { view.setTranslationY(startOffsetY); slide.translationY(endTranslateY); } else { view.setTranslationX(startOffsetX); slide.translationX(endTranslateX); } slide.setInterpolator(new DecelerateInterpolator(2)); slide.setDuration(res.getInteger(R.integer.material_in_slide_anim_duration)); slide.setStartDelay(delay); slide.setListener(new AnimatorListenerAdapter() { @Override public void onAnimationCancel(Animator animation) { if (fade.isStarted()) { fade.cancel(); } view.setAlpha(endAlpha); view.setTranslationX(endTranslateX); view.setTranslationY(endTranslateY); } }); slide.start(); } }
@Override public SkinAnimator apply(@NonNull final View view, @Nullable final Action action) { int offset = -view.getWidth() / 2; animator = ObjectAnimator.ofPropertyValuesHolder(view, PropertyValuesHolder.ofFloat("alpha", 1, 0), PropertyValuesHolder.ofFloat("translationX", 0, - offset, -offset, offset, offset, 0), PropertyValuesHolder.ofFloat("rotation", 0, -30, -30, 30, 30, 0), PropertyValuesHolder.ofFloat("translationY", 0, 3 * view.getHeight()) ); animator.setDuration(5 * PRE_DURATION); animator.setInterpolator(new LinearInterpolator()); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); resetView(view); if (action != null) { action.action(); } } }); return this; }
@Override public void animate( View from, View to, NavigationType navType, Direction direction, final Callback callback) { int[] clickedViewCenter = getCenterClickedView((ViewGroup) from); int circularRevealCenterX = clickedViewCenter[0]; int circularRevealCenterY = clickedViewCenter[1]; float finalRadius = (float) Math.hypot(to.getWidth(), to.getHeight()); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { Animator anim = ViewAnimationUtils.createCircularReveal(to, circularRevealCenterX, circularRevealCenterY, 0, finalRadius); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { callback.onAnimationEnd(); } }); anim.start(); } else { callback.onAnimationEnd(); } }
private void performDismissAnimation() { contextMenuView.setPivotX(contextMenuView.getWidth() / 2); contextMenuView.setPivotY(contextMenuView.getHeight()); contextMenuView.animate() .scaleX(0.1f).scaleY(0.1f) .setDuration(150) .setInterpolator(new AccelerateInterpolator()) .setStartDelay(100) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (contextMenuView != null) { contextMenuView.dismiss(); } isContextMenuDismissing = false; } }); }
@BindingAdapter({"android:visibility"}) public static void visibility(final View view, final int newVisibility) { final boolean makeVisible = newVisibility == View.VISIBLE; if (makeVisible) { view.setVisibility(newVisibility); } view.animate() .alpha(makeVisible ? 1.0f : 0.0f) .setDuration(500) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); if (!makeVisible) { view.setVisibility(newVisibility); } } }); }
/** * Анимация прозрачного перехода между двумя view * * @param inView view, которая будет показана после завершения анимации * @param outView view, которая будет исчезать * @param duration длительность анимации */ public static void crossfade(final View inView, final View outView, final long duration) { inView.setAlpha(0f); inView.setVisibility(View.VISIBLE); inView.animate().alpha(1f).setDuration(duration).setListener(null); outView.animate() .alpha(0f) .setDuration(duration) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { outView.setVisibility(View.GONE); } }); }
/** Dismisses this results bar by removing it from the view hierarchy. */ public void dismiss() { mDismissing = true; mFindInPageBridge = null; if (mVisibilityAnimation != null && mVisibilityAnimation.isRunning()) { mVisibilityAnimation.cancel(); } mVisibilityAnimation = ObjectAnimator.ofFloat(this, TRANSLATION_X, MathUtils.flipSignIf(mBarTouchWidth, LocalizationUtils.isLayoutRtl())); mVisibilityAnimation.setDuration(VISIBILITY_ANIMATION_DURATION_MS); mVisibilityAnimation.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE); mTab.getWindowAndroid().startAnimationOverContent(mVisibilityAnimation); mVisibilityAnimation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); if (getParent() != null) ((ViewGroup) getParent()).removeView(FindResultBar.this); } }); }
private void runIconScale(int delay, @DrawableRes int drawable, int color){ soundPlay.animate() .scaleY(0) .scaleX(0) .setDuration(duration(R.integer.short_delay)) .setStartDelay(delay) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); trackTitle.setTextColor(color); soundPlay.setImageDrawable(ContextCompat.getDrawable(getContext(),drawable)); soundPlay.animate() .scaleX(1) .scaleY(1) .setDuration(duration(R.integer.scale_duration)) .setListener(null).start(); } }).start(); }