List of usage examples for android.animation AnimatorListenerAdapter AnimatorListenerAdapter
AnimatorListenerAdapter
From source file:com.folioreader.activity.FolioActivity.java
private void toolbarAnimateHide() { mToolbar.animate().translationY(-mToolbar.getHeight()).setInterpolator(new LinearInterpolator()) .setDuration(180).setListener(new AnimatorListenerAdapter() { @Override// w ww .ja v a 2s. co m public void onAnimationEnd(Animator animation) { toolbarSetElevation(0); } }); mIsActionBarVisible = false; }
From source file:com.l4digital.fastscroll.FastScroller.java
private void hideScrollbar() { float transX = getResources().getDimensionPixelSize(R.dimen.fastscroll_scrollbar_padding); mScrollbarAnimator = mScrollbar.animate().translationX(transX).alpha(0f).setDuration(sScrollbarAnimDuration) .setListener(new AnimatorListenerAdapter() { @Override/*from w ww . ja v a2s .c o m*/ public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); mScrollbar.setVisibility(GONE); mScrollbarAnimator = null; } @Override public void onAnimationCancel(Animator animation) { super.onAnimationCancel(animation); mScrollbar.setVisibility(GONE); mScrollbarAnimator = null; } }); }
From source file:com.example.customview.DynamicListView.java
/** * Resets all the appropriate fields to a default state while also animating * the hover cell back to its correct location. *//*from w ww . ja v a 2 s . c o m*/ private void touchEventsEnded() { final View mobileView = getViewForID(mMobileItemId); if (mCellIsMobile || mIsWaitingForScrollFinish) { mCellIsMobile = false; mIsWaitingForScrollFinish = false; mIsMobileScrolling = false; mActivePointerId = INVALID_POINTER_ID; // If the autoscroller has not completed scrolling, we need to wait for it to // finish in order to determine the final location of where the hover cell // should be animated to. if (mScrollState != OnScrollListener.SCROLL_STATE_IDLE) { mIsWaitingForScrollFinish = true; return; } mHoverCellCurrentBounds.offsetTo(mHoverCellOriginalBounds.left, mobileView.getTop()); ObjectAnimator hoverViewAnimator = ObjectAnimator.ofObject(mHoverCell, "bounds", sBoundEvaluator, mHoverCellCurrentBounds); hoverViewAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { invalidate(); } }); hoverViewAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { setEnabled(false); } @Override public void onAnimationEnd(Animator animation) { mAboveItemId = INVALID_ID; mMobileItemId = INVALID_ID; mBelowItemId = INVALID_ID; mobileView.setVisibility(VISIBLE); mHoverCell = null; setEnabled(true); invalidate(); } }); hoverViewAnimator.start(); } else { touchEventsCancelled(); } }
From source file:com.android.contacts.activities.PhotoSelectionActivity.java
private void animatePhotoOpen() { mAnimationListener = new AnimatorListenerAdapter() { private void capturePhotoPos() { mPhotoView.requestLayout();/*from w w w. j a v a 2s . com*/ mOriginalPos.left = mPhotoView.getLeft(); mOriginalPos.top = mPhotoView.getTop(); mOriginalPos.right = mPhotoView.getRight(); mOriginalPos.bottom = mPhotoView.getBottom(); } @Override public void onAnimationEnd(Animator animation) { capturePhotoPos(); if (mPhotoHandler != null) { mPhotoHandler.onClick(mPhotoView); } } @Override public void onAnimationCancel(Animator animation) { capturePhotoPos(); } }; animatePhoto(getPhotoEndParams()); }
From source file:com.android.volley.cache.plus.SimpleImageLoader.java
/** * Sets a {@link android.graphics.Bitmap} to an {@link android.widget.ImageView} using a * fade-in animation. If there is a {@link android.graphics.drawable.Drawable} already set on * the ImageView then use that as the image to fade from. Otherwise fade in from a transparent * Drawable.//from w w w.ja v a 2 s . co m */ @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1) private static void setPhotoImageBitmap(final PhotoView imageView, final BitmapDrawable bitmapDrawable, Resources resources, boolean fadeIn) { // If we're fading in and on HC MR1+ if (fadeIn && Utils.hasHoneycombMR1()) { // Use ViewPropertyAnimator to run a simple fade in + fade out animation to update the // ImageView imageView.animate().scaleY(0.95f).scaleX(0.95f).alpha(0f) .setDuration(imageView.getDrawable() == null ? 0 : HALF_FADE_IN_TIME) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { imageView.bindDrawable(bitmapDrawable); imageView.animate().alpha(1f).scaleY(1f).scaleX(1f).setDuration(HALF_FADE_IN_TIME) .setListener(null); } }); } else if (fadeIn) { // Otherwise use a TransitionDrawable to fade in Drawable initialDrawable; if (imageView.getDrawable() != null) { initialDrawable = imageView.getDrawable(); } else { initialDrawable = transparentDrawable; } // Use TransitionDrawable to fade in final TransitionDrawable td = new TransitionDrawable( new Drawable[] { initialDrawable, bitmapDrawable }); imageView.bindDrawable(td); td.startTransition(Utils.ANIMATION_FADE_IN_TIME); } else { // No fade in, just set bitmap directly imageView.bindDrawable(bitmapDrawable); } }
From source file:com.android.volley.cache.SimpleImageLoader.java
/** * Sets a {@link android.graphics.Bitmap} to an {@link android.widget.ImageView} using a * fade-in animation. If there is a {@link android.graphics.drawable.Drawable} already set on * the ImageView then use that as the image to fade from. Otherwise fade in from a transparent * Drawable.//from w w w .java 2 s .c o m */ @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1) private static void setPhotoImageBitmap(final PhotoView imageView, final Bitmap bitmap, Resources resources, boolean fadeIn) { // If we're fading in and on HC MR1+ if (fadeIn && Utils.hasHoneycombMR1()) { // Use ViewPropertyAnimator to run a simple fade in + fade out animation to update the // ImageView imageView.animate().scaleY(0.95f).scaleX(0.95f).alpha(0f) .setDuration(imageView.getDrawable() == null ? 0 : HALF_FADE_IN_TIME) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { imageView.bindPhoto(bitmap); imageView.animate().alpha(1f).scaleY(1f).scaleX(1f).setDuration(HALF_FADE_IN_TIME) .setListener(null); } }); } else if (fadeIn) { // Otherwise use a TransitionDrawable to fade in Drawable initialDrawable; if (imageView.getDrawable() != null) { initialDrawable = imageView.getDrawable(); } else { initialDrawable = transparentDrawable; } BitmapDrawable bitmapDrawable = new BitmapDrawable(resources, bitmap); // Use TransitionDrawable to fade in final TransitionDrawable td = new TransitionDrawable( new Drawable[] { initialDrawable, bitmapDrawable }); imageView.bindDrawable(td); td.startTransition(Utils.ANIMATION_FADE_IN_TIME); } else { // No fade in, just set bitmap directly imageView.bindPhoto(bitmap); } }
From source file:ca.taglab.PictureFrame.ScreenSlidePageFragment.java
private void hideOptions() { mPhoto.animate().alpha(0f).setDuration(mShortAnimationDuration).setListener(new AnimatorListenerAdapter() { @Override//from ww w. j a v a 2 s . com public void onAnimationEnd(Animator animation) { mPhoto.setVisibility(View.GONE); } }); mVideo.animate().alpha(0f).setDuration(mShortAnimationDuration).setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mVideo.setVisibility(View.GONE); } }); mAudio.animate().alpha(0f).setDuration(mShortAnimationDuration).setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mAudio.setVisibility(View.GONE); } }); mWave.animate().alpha(0f).setDuration(mShortAnimationDuration).setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mWave.setVisibility(View.GONE); } }); mCancel.animate().alpha(0f).setDuration(mShortAnimationDuration).setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mCancel.setVisibility(View.INVISIBLE); } }); optionsOpen = false; }
From source file:com.arlib.floatingsearchview.util.view.MenuView.java
/** * Shows all the menu items that were hidden by hideIfRoomItems(boolean withAnim) * * @param withAnim/*from ww w. j a v a 2 s. c o m*/ */ public void showIfRoomItems(boolean withAnim) { if (mMenu == -1) return; cancelChildAnimListAndClear(); if (mMenuItems.isEmpty()) return; anims = new ArrayList<>(); for (int i = 0; i < getChildCount(); i++) { final View currentView = getChildAt(i); if (i < mActionItems.size()) { ImageView action = (ImageView) currentView; final MenuItem actionItem = mActionItems.get(i); action.setImageDrawable(Util.setIconColor(actionItem.getIcon(), mActionIconColor)); action.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mMenuCallback != null) mMenuCallback.onMenuItemSelected(mMenuBuilder, actionItem); } }); } //todo go over logic int animDuration = withAnim ? SHOW_IF_ROOM_ITEMS_ANIM_DURATION : 0; Interpolator interpolator = new DecelerateInterpolator(); //todo check logic if (i > mActionShowAlwaysItems.size() - 1) interpolator = new LinearInterpolator(); currentView.setClickable(true); anims.add(ViewPropertyObjectAnimator.animate(currentView).addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { currentView.setTranslationX(0); } }).setInterpolator(interpolator).setDuration(animDuration).translationX(0).get()); anims.add(ViewPropertyObjectAnimator.animate(currentView).addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { currentView.setScaleX(1.0f); } }).setInterpolator(interpolator).setDuration(animDuration).scaleX(1.0f).get()); anims.add(ViewPropertyObjectAnimator.animate(currentView).addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { currentView.setScaleY(1.0f); } }).setInterpolator(interpolator).setDuration(animDuration).scaleY(1.0f).get()); anims.add(ViewPropertyObjectAnimator.animate(currentView).addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { currentView.setAlpha(1.0f); } }).setInterpolator(interpolator).setDuration(animDuration).alpha(1.0f).get()); } AnimatorSet animSet = new AnimatorSet(); //temporary, from laziness if (!withAnim) animSet.setDuration(0); animSet.playTogether(anims.toArray(new ObjectAnimator[anims.size()])); animSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (mOnVisibleWidthChanged != null) mOnVisibleWidthChanged.onVisibleWidthChanged( (getChildCount() * (int) ACTION_DIMENSION_PX) - (mHasOverflow ? Util.dpToPx(8) : 0)); } }); animSet.start(); }
From source file:com.gu.swiperefresh.ProgressDrawable.java
private void setupAnimators() { final Ring ring = mRing; final ValueAnimator animator = ObjectAnimator.ofFloat(0f, 1f); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override/*from w w w . j a v a2 s. c om*/ public void onAnimationUpdate(ValueAnimator animation) { float interpolatedTime = Float.valueOf(animation.getAnimatedValue().toString()); if (mFinishing) { applyFinishTranslation(interpolatedTime, ring); } else { // The minProgressArc is calculated from 0 to create an // angle that matches the stroke width. final float minProgressArc = getMinProgressArc(ring); final float startingEndTrim = ring.getStartingEndTrim(); final float startingTrim = ring.getStartingStartTrim(); final float startingRotation = ring.getStartingRotation(); updateRingColor(interpolatedTime, ring); // Moving the start trim only occurs in the first 50% of a // single ring animation if (interpolatedTime <= START_TRIM_DURATION_OFFSET) { // scale the interpolatedTime so that the full // transformation from 0 - 1 takes place in the // remaining time final float scaledTime = (interpolatedTime) / (1.0f - START_TRIM_DURATION_OFFSET); final float startTrim = startingTrim + ((MAX_PROGRESS_ARC - minProgressArc) * MATERIAL_INTERPOLATOR.getInterpolation(scaledTime)); ring.setStartTrim(startTrim); } // Moving the end trim starts after 50% of a single ring // animation completes if (interpolatedTime > END_TRIM_START_DELAY_OFFSET) { // scale the interpolatedTime so that the full // transformation from 0 - 1 takes place in the // remaining time final float minArc = MAX_PROGRESS_ARC - minProgressArc; float scaledTime = (interpolatedTime - START_TRIM_DURATION_OFFSET) / (1.0f - START_TRIM_DURATION_OFFSET); final float endTrim = startingEndTrim + (minArc * MATERIAL_INTERPOLATOR.getInterpolation(scaledTime)); ring.setEndTrim(endTrim); } final float rotation = startingRotation + (0.25f * interpolatedTime); ring.setRotation(rotation); float groupRotation = ((FULL_ROTATION / NUM_POINTS) * interpolatedTime) + (FULL_ROTATION * (mRotationCount / NUM_POINTS)); setRotation(groupRotation); } } }); animator.setRepeatCount(Animation.INFINITE); animator.setRepeatMode(ValueAnimator.RESTART); animator.setInterpolator(LINEAR_INTERPOLATOR); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { } @Override public void onAnimationStart(Animator animation) { mRotationCount = 0; } @Override public void onAnimationRepeat(Animator animation) { ring.storeOriginals(); ring.goToNextColor(); ring.setStartTrim(ring.getEndTrim()); if (mFinishing) { // finished closing the last ring from the swipe gesture; go // into progress mode mFinishing = false; animation.setDuration(ANIMATION_DURATION); ring.setShowArrow(false); } else { mRotationCount = (mRotationCount + 1) % (NUM_POINTS); } } }); mAnimation = animator; }
From source file:com.itsronald.widget.IndicatorDotPathView.java
@NonNull private Animator retreatCenterSegmentAnimator(final float toX, final float toY, final long animationDuration) { final float originalScale = 1, scaleX = 0, scaleY = 1; final Animator animator = scaleAnimator(centerSegment, originalScale, scaleX, scaleY); // Choose the corner of the view farthest from the destination location. final float originalPivotX = getPivotX(); final float originalPivotY = getPivotY(); final float pivotX = Math.max(0, Math.min(toX, centerSegment.getWidth())); final float pivotY = Math.max(0, Math.min(toY, centerSegment.getHeight())); animator.addListener(new AnimatorListenerAdapter() { @Override/*from w w w. j a va 2s. c o m*/ public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); centerSegment.setPivotX(pivotX); centerSegment.setPivotY(pivotY); } @Override public void onAnimationEnd(Animator animation) { // Reset values. centerSegment.setVisibility(INVISIBLE); centerSegment.setScaleX(originalScale); centerSegment.setScaleY(originalScale); centerSegment.setPivotX(originalPivotX); centerSegment.setPivotY(originalPivotY); } }); animator.setDuration(animationDuration); return animator; }