Here are the examples of the java api class android.view.animation.Interpolator taken from open source projects.
1. MultiListView#initPullImageAnimation()
Project: WifiChat
File: MultiListView.java
File: MultiListView.java
/** * ??????????????? * * @param pAnimDuration * ?????? * @date 2015?2?14? ??11:17 * @change hillfly */ private void initPullImageAnimation(final int pAnimDuration) { int _Duration; if (pAnimDuration > 0) { _Duration = pAnimDuration; } else { _Duration = 250; } Interpolator _Interpolator = new LinearInterpolator(); mArrowAnim = new RotateAnimation(0, -180, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f); mArrowAnim.setInterpolator(_Interpolator); mArrowAnim.setDuration(_Duration); mArrowAnim.setFillAfter(true); mArrowReverseAnim = new RotateAnimation(-180, 0, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f); mArrowReverseAnim.setInterpolator(_Interpolator); mArrowReverseAnim.setDuration(_Duration); mArrowReverseAnim.setFillAfter(true); }
2. PullDoorView#setupView()
Project: UltimateAndroid
File: PullDoorView.java
File: PullDoorView.java
@SuppressLint("NewApi") private void setupView() { // ??Interpolator??????? ?????????????Interpolator Interpolator polator = new BounceInterpolator(); mScroller = new Scroller(mContext, polator); // ??????? WindowManager wm = (WindowManager) (mContext.getSystemService(Context.WINDOW_SERVICE)); DisplayMetrics dm = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(dm); mScreenHeigh = dm.heightPixels; mScreenWidth = dm.widthPixels; // ?????????????,???????????? this.setBackgroundColor(Color.argb(0, 0, 0, 0)); mImgView = new ImageView(mContext); mImgView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); // ?????? mImgView.setScaleType(ImageView.ScaleType.FIT_XY); // ???? mImgView.setImageResource(R.drawable.test); addView(mImgView); }
3. PullDoorView#setupView()
Project: UltimateAndroid
File: PullDoorView.java
File: PullDoorView.java
@SuppressLint("NewApi") private void setupView() { Interpolator polator = new BounceInterpolator(); mScroller = new Scroller(mContext, polator); WindowManager wm = (WindowManager) (mContext.getSystemService(Context.WINDOW_SERVICE)); DisplayMetrics dm = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(dm); mScreenHeigh = dm.heightPixels; mScreenWidth = dm.widthPixels; this.setBackgroundColor(Color.argb(0, 0, 0, 0)); mImgView = new ImageView(mContext); mImgView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); mImgView.setScaleType(ImageView.ScaleType.FIT_XY); mImgView.setImageResource(R.drawable.circle_button_ic_action_tick); addView(mImgView); }
4. SizeChange#changeSize()
Project: ud862-samples
File: SizeChange.java
File: SizeChange.java
public void changeSize(View view) { Interpolator interpolator = AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in); ObjectAnimator scaleX = ObjectAnimator.ofFloat(card, View.SCALE_X, (small ? LARGE_SCALE : 1f)); scaleX.setInterpolator(interpolator); scaleX.setDuration(symmetric ? 600L : 200L); ObjectAnimator scaleY = ObjectAnimator.ofFloat(card, View.SCALE_Y, (small ? LARGE_SCALE : 1f)); scaleY.setInterpolator(interpolator); scaleY.setDuration(600L); scaleX.start(); scaleY.start(); // toggle the state so that we switch between large/small and symmetric/asymmetric small = !small; if (small) { symmetric = !symmetric; } }
5. MultipleElements#animateViewsIn()
Project: ud862-samples
File: MultipleElements.java
File: MultipleElements.java
private void animateViewsIn() { ViewGroup root = (ViewGroup) findViewById(R.id.root); int count = root.getChildCount(); float offset = getResources().getDimensionPixelSize(R.dimen.offset_y); Interpolator interpolator = AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in); // duration + interpolation for (int i = 0; i < count; i++) { View view = root.getChildAt(i); view.setVisibility(View.VISIBLE); view.setTranslationY(offset); view.setAlpha(0.85f); // then animate back to natural position view.animate().translationY(0f).alpha(1f).setInterpolator(interpolator).setDuration(1000L).start(); // increase the offset distance for the next view offset *= 1.5f; } }
6. SingleInputFormActivity#getAnimation()
Project: material-singleinputform
File: SingleInputFormActivity.java
File: SingleInputFormActivity.java
private Animation getAnimation(int animationResId, boolean isInAnimation) { final Interpolator interpolator; if (isInAnimation) { interpolator = new DecelerateInterpolator(1.0f); } else { interpolator = new AccelerateInterpolator(1.0f); } Animation animation = AnimationUtils.loadAnimation(this, animationResId); animation.setInterpolator(interpolator); return animation; }
7. SFVehiclesActivity#animateMarkerTo()
Project: geofire-java
File: SFVehiclesActivity.java
File: SFVehiclesActivity.java
// Animation handler for old APIs without animation support private void animateMarkerTo(final Marker marker, final double lat, final double lng) { final Handler handler = new Handler(); final long start = SystemClock.uptimeMillis(); final long DURATION_MS = 3000; final Interpolator interpolator = new AccelerateDecelerateInterpolator(); final LatLng startPosition = marker.getPosition(); handler.post(new Runnable() { @Override public void run() { float elapsed = SystemClock.uptimeMillis() - start; float t = elapsed / DURATION_MS; float v = interpolator.getInterpolation(t); double currentLat = (lat - startPosition.latitude) * v + startPosition.latitude; double currentLng = (lng - startPosition.longitude) * v + startPosition.longitude; marker.setPosition(new LatLng(currentLat, currentLng)); // if animation is not finished yet, repeat if (t < 1) { handler.postDelayed(this, 16); } } }); }
8. ExpandableSelectorAnimator#collapseContainer()
Project: ExpandableSelector
File: ExpandableSelectorAnimator.java
File: ExpandableSelectorAnimator.java
private void collapseContainer(final Listener listener) { float toWidth = container.getWidth(); float toHeight = getFirstItemHeight(); Interpolator interpolator = getContainerAnimationInterpolator(); ResizeAnimation resizeAnimation = createResizeAnimation(toWidth, interpolator, toHeight, new Listener() { @Override public void onAnimationFinished() { changeButtonsVisibility(View.INVISIBLE); listener.onAnimationFinished(); } }); container.startAnimation(resizeAnimation); }
9. CheckTextView#createAnimations()
Project: EhViewer
File: CheckTextView.java
File: CheckTextView.java
private void createAnimations() { float startRadius; float endRadius; Interpolator interpolator; if (mChecked) { startRadius = 0; endRadius = mMaxRadius; interpolator = AnimationUtils.FAST_SLOW_INTERPOLATOR; } else { startRadius = mMaxRadius; endRadius = 0; interpolator = AnimationUtils.SLOW_FAST_INTERPOLATOR; } mRadius = startRadius; final ObjectAnimator radiusAnim = ObjectAnimator.ofFloat(this, "radius", startRadius, endRadius); radiusAnim.setDuration(ANIMATION_DURATION); radiusAnim.setInterpolator(interpolator); radiusAnim.addListener(mAnimatorListener); radiusAnim.start(); mAnimator = radiusAnim; }
10. InterpolateActivity#init()
Project: XDroidAnimation
File: InterpolateActivity.java
File: InterpolateActivity.java
private void init() { interpolatorList.add(new EaseBackInInterpolator()); interpolatorList.add(new EaseBackOutInterpolator()); interpolatorList.add(new EaseBackInOutInterpolator()); interpolatorList.add(new EaseBounceInInterpolator()); interpolatorList.add(new EaseBounceOutInterpolator()); interpolatorList.add(new EaseBounceInOutInterpolator()); interpolatorList.add(new EaseCircularInInterpolator()); interpolatorList.add(new EaseCircularOutInterpolator()); interpolatorList.add(new EaseCircularInOutInterpolator()); interpolatorList.add(new EaseCubicInInterpolator()); interpolatorList.add(new EaseCubicOutInterpolator()); interpolatorList.add(new EaseCubicInOutInterpolator()); interpolatorList.add(new EaseElasticInInterpolator(DURATION)); interpolatorList.add(new EaseElasticOutInterpolator(DURATION)); interpolatorList.add(new EaseElasticInOutInterpolator(DURATION)); interpolatorList.add(new EaseExponentialInInterpolator()); interpolatorList.add(new EaseExponentialOutInterpolator()); interpolatorList.add(new EaseExponentialInOutInterpolator()); interpolatorList.add(new EaseQuadInInterpolator()); interpolatorList.add(new EaseQuadOutInterpolator()); interpolatorList.add(new EaseQuadInOutInterpolator()); interpolatorList.add(new EaseQuartInInterpolator()); interpolatorList.add(new EaseQuartOutInterpolator()); interpolatorList.add(new EaseQuartInOutInterpolator()); interpolatorList.add(new EaseQuintInInterpolator()); interpolatorList.add(new EaseQuintOutInterpolator()); interpolatorList.add(new EaseQuintInOutInterpolator()); interpolatorList.add(new EaseSineInInterpolator()); interpolatorList.add(new EaseSineOutInterpolator()); interpolatorList.add(new EaseSineInOutInterpolator()); for (Interpolator interpolator : interpolatorList) { nameList.add(interpolator.getClass().getSimpleName().replace("Interpolator", "")); } }
11. EaseAdapter#getView()
Project: XDroidAnimation
File: EaseAdapter.java
File: EaseAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { mHolder = new ViewHolder(); convertView = mInflater.inflate(R.layout.adapter, null); convertView.setBackgroundColor(Color.WHITE); mHolder.easeName = (TextView) convertView.findViewById(R.id.easeName); mHolder.easeView = (EaseView) convertView.findViewById(R.id.easeView); mHolder.cursor = (CursorView) convertView.findViewById(R.id.cursor); convertView.setTag(mHolder); } else { mHolder = (ViewHolder) convertView.getTag(); } final Interpolator interpolator = mInterpolatorList.get(position); mHolder.easeName.setText(mNameList.get(position)); mHolder.easeView.setDurationAndInterpolator(duration, interpolator); int bottomMargin = mHolder.easeView.blankTB - mHolder.cursor.height / 2; LayoutParams params = (LayoutParams) mHolder.cursor.getLayoutParams(); params.addRule(RelativeLayout.ALIGN_BOTTOM, R.id.easeView); params.bottomMargin = bottomMargin; mHolder.cursor.setLayoutParams(params); if (position == selectIndex) { //??????Ease?? selectIndex = -1; int toYDelta = mHolder.easeView.height - 2 * mHolder.easeView.blankTB; Animation anim = new TranslateAnimation(0, 0, 0, -toYDelta); anim.setDuration(duration); anim.setInterpolator(interpolator); anim.setFillAfter(true); anim.setFillBefore(true); anim.setStartOffset(300); mHolder.cursor.startAnimation(anim); } else { //??????????? Animation anim = new TranslateAnimation(0, 0, 0, 0); anim.setDuration(0); anim.setFillAfter(true); anim.setFillBefore(true); mHolder.cursor.startAnimation(anim); } return convertView; }
12. MainActivity#onItemSelected()
Project: WaveDrawable
File: MainActivity.java
File: MainActivity.java
@Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { Interpolator interpolator; switch(position) { case 0: interpolator = new LinearInterpolator(); break; case 1: interpolator = new AccelerateDecelerateInterpolator(); break; case 2: interpolator = new AccelerateInterpolator(); break; case 3: interpolator = new AnticipateInterpolator(); break; case 4: interpolator = new AnticipateOvershootInterpolator(); break; case 5: interpolator = new BounceInterpolator(); break; case 6: interpolator = new CycleInterpolator(3); break; case 7: interpolator = new DecelerateInterpolator(); break; case 8: interpolator = new OvershootInterpolator(); break; default: interpolator = new LinearInterpolator(); break; } waveDrawable.setWaveInterpolator(interpolator); waveDrawable.startAnimation(); }
13. RayLayout#bindChildAnimation()
Project: UltimateAndroid
File: RayLayout.java
File: RayLayout.java
private void bindChildAnimation(final View child, final int index, final long duration) { final boolean expanded = mExpanded; final int childCount = getChildCount(); Rect frame = computeChildFrame(!expanded, mLeftHolderWidth, index, mChildGap, mChildSize); final int toXDelta = frame.left - child.getLeft(); final int toYDelta = frame.top - child.getTop(); Interpolator interpolator = mExpanded ? new AccelerateInterpolator() : new OvershootInterpolator(1.5f); final long startOffset = computeStartOffset(childCount, mExpanded, index, 0.1f, duration, interpolator); Animation animation = mExpanded ? createShrinkAnimation(0, toXDelta, 0, toYDelta, startOffset, duration, interpolator) : createExpandAnimation(0, toXDelta, 0, toYDelta, startOffset, duration, interpolator); final boolean isLast = getTransformedIndex(expanded, childCount, index) == childCount - 1; animation.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { if (isLast) { postDelayed(new Runnable() { @Override public void run() { onAllAnimationsEnd(); } }, 0); } } }); child.setAnimation(animation); }
14. ArcLayout#bindChildAnimation()
Project: UltimateAndroid
File: ArcLayout.java
File: ArcLayout.java
private void bindChildAnimation(final View child, final int index, final long duration) { final boolean expanded = mExpanded; final int centerX = getWidth() / 2; final int centerY = getHeight() / 2; final int radius = expanded ? 0 : mRadius; final int childCount = getChildCount(); final float perDegrees = (mToDegrees - mFromDegrees) / (childCount - 1); Rect frame = computeChildFrame(centerX, centerY, radius, mFromDegrees + index * perDegrees, mChildSize); final int toXDelta = frame.left - child.getLeft(); final int toYDelta = frame.top - child.getTop(); Interpolator interpolator = mExpanded ? new AccelerateInterpolator() : new OvershootInterpolator(1.5f); final long startOffset = computeStartOffset(childCount, mExpanded, index, 0.1f, duration, interpolator); Animation animation = mExpanded ? createShrinkAnimation(0, toXDelta, 0, toYDelta, startOffset, duration, interpolator) : createExpandAnimation(0, toXDelta, 0, toYDelta, startOffset, duration, interpolator); final boolean isLast = getTransformedIndex(expanded, childCount, index) == childCount - 1; animation.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { if (isLast) { postDelayed(new Runnable() { @Override public void run() { onAllAnimationsEnd(); } }, 0); } } }); child.setAnimation(animation); }
15. RayLayout#bindChildAnimation()
Project: UltimateAndroid
File: RayLayout.java
File: RayLayout.java
private void bindChildAnimation(final View child, final int index, final long duration) { final boolean expanded = mExpanded; final int childCount = getChildCount(); Rect frame = computeChildFrame(!expanded, mLeftHolderWidth, index, mChildGap, mChildSize); final int toXDelta = frame.left - child.getLeft(); final int toYDelta = frame.top - child.getTop(); Interpolator interpolator = mExpanded ? new AccelerateInterpolator() : new OvershootInterpolator(1.5f); final long startOffset = computeStartOffset(childCount, mExpanded, index, 0.1f, duration, interpolator); Animation animation = mExpanded ? createShrinkAnimation(0, toXDelta, 0, toYDelta, startOffset, duration, interpolator) : createExpandAnimation(0, toXDelta, 0, toYDelta, startOffset, duration, interpolator); final boolean isLast = getTransformedIndex(expanded, childCount, index) == childCount - 1; animation.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { if (isLast) { postDelayed(new Runnable() { @Override public void run() { onAllAnimationsEnd(); } }, 0); } } }); child.setAnimation(animation); }
16. ArcLayout#bindChildAnimation()
Project: UltimateAndroid
File: ArcLayout.java
File: ArcLayout.java
private void bindChildAnimation(final View child, final int index, final long duration) { final boolean expanded = mExpanded; final int centerX = getWidth() / 2; final int centerY = getHeight() / 2; final int radius = expanded ? 0 : mRadius; final int childCount = getChildCount(); final float perDegrees = (mToDegrees - mFromDegrees) / (childCount - 1); Rect frame = computeChildFrame(centerX, centerY, radius, mFromDegrees + index * perDegrees, mChildSize); final int toXDelta = frame.left - child.getLeft(); final int toYDelta = frame.top - child.getTop(); Interpolator interpolator = mExpanded ? new AccelerateInterpolator() : new OvershootInterpolator(1.5f); final long startOffset = computeStartOffset(childCount, mExpanded, index, 0.1f, duration, interpolator); Animation animation = mExpanded ? createShrinkAnimation(0, toXDelta, 0, toYDelta, startOffset, duration, interpolator) : createExpandAnimation(0, toXDelta, 0, toYDelta, startOffset, duration, interpolator); final boolean isLast = getTransformedIndex(expanded, childCount, index) == childCount - 1; animation.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { if (isLast) { postDelayed(new Runnable() { @Override public void run() { onAllAnimationsEnd(); } }, 0); } } }); child.setAnimation(animation); }
17. MultipleChaoticElements#animateViewsIn()
Project: ud862-samples
File: MultipleChaoticElements.java
File: MultipleChaoticElements.java
private void animateViewsIn() { // setup random initial state ViewGroup root = (ViewGroup) findViewById(R.id.root); float maxWidthOffset = 2f * getResources().getDisplayMetrics().widthPixels; float maxHeightOffset = 2f * getResources().getDisplayMetrics().heightPixels; Interpolator interpolator = AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in); Random random = new Random(); int count = root.getChildCount(); for (int i = 0; i < count; i++) { View view = root.getChildAt(i); view.setVisibility(View.VISIBLE); view.setAlpha(0.85f); float xOffset = random.nextFloat() * maxWidthOffset; if (random.nextBoolean()) { xOffset *= -1; } view.setTranslationX(xOffset); float yOffset = random.nextFloat() * maxHeightOffset; if (random.nextBoolean()) { yOffset *= -1; } view.setTranslationY(yOffset); // now animate them back into their natural position view.animate().translationY(0f).translationX(0f).alpha(1f).setInterpolator(interpolator).setDuration(1000).start(); } }
18. FabDialogMorphSetup#setupSharedEelementTransitions()
Project: sbt-android
File: FabDialogMorphSetup.java
File: FabDialogMorphSetup.java
/** * Configure the shared element transitions for morphin from a fab <-> dialog. We need to do * this in code rather than declaratively as we need to supply the color to transition from/to * and the dialog corner radius which is dynamically supplied depending upon where this screen * is launched from. */ public static void setupSharedEelementTransitions(@NonNull Activity activity, @Nullable View target, int dialogCornerRadius) { if (!activity.getIntent().hasExtra(EXTRA_SHARED_ELEMENT_START_COLOR)) return; int startCornerRadius = activity.getIntent().getIntExtra(EXTRA_SHARED_ELEMENT_START_CORNER_RADIUS, -1); ArcMotion arcMotion = new ArcMotion(); arcMotion.setMinimumHorizontalAngle(50f); arcMotion.setMinimumVerticalAngle(50f); int color = activity.getIntent().getIntExtra(EXTRA_SHARED_ELEMENT_START_COLOR, Color.TRANSPARENT); Interpolator easeInOut = AnimationUtils.loadInterpolator(activity, android.R.interpolator.fast_out_slow_in); MorphFabToDialog sharedEnter = new MorphFabToDialog(color, dialogCornerRadius, startCornerRadius); sharedEnter.setPathMotion(arcMotion); sharedEnter.setInterpolator(easeInOut); MorphDialogToFab sharedReturn = new MorphDialogToFab(color, startCornerRadius); sharedReturn.setPathMotion(arcMotion); sharedReturn.setInterpolator(easeInOut); if (target != null) { sharedEnter.addTarget(target); sharedReturn.addTarget(target); } activity.getWindow().setSharedElementEnterTransition(sharedEnter); activity.getWindow().setSharedElementReturnTransition(sharedReturn); }
19. DribbbleShot#enterAnimation()
Project: sbt-android
File: DribbbleShot.java
File: DribbbleShot.java
/** * Animate in the title, description and author – can't do this in a content transition as they * are within the ListView so do it manually. Also handle the FAB tanslation here so that it * plays nicely with #calculateFabPosition */ private void enterAnimation() { Interpolator interp = AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in); int offset = title.getHeight(); viewEnterAnimation(title, offset, interp); if (description.getVisibility() == View.VISIBLE) { offset *= 1.5f; viewEnterAnimation(description, offset, interp); } // animate the fab without touching the alpha as this is handled in the content transition offset *= 1.5f; float fabTransY = fab.getTranslationY(); fab.setTranslationY(fabTransY + offset); fab.animate().translationY(fabTransY).setDuration(600).setInterpolator(interp).start(); offset *= 1.5f; viewEnterAnimation(shotActions, offset, interp); offset *= 1.5f; viewEnterAnimation(playerName, offset, interp); viewEnterAnimation(playerAvatar, offset, interp); viewEnterAnimation(shotTimeAgo, offset, interp); back.animate().alpha(1f).setDuration(600).setInterpolator(interp).start(); }
20. AbstractLayoutAnimation#getInterpolator()
Project: react-native
File: AbstractLayoutAnimation.java
File: AbstractLayoutAnimation.java
private static Interpolator getInterpolator(InterpolatorType type) { Interpolator interpolator = INTERPOLATOR.get(type); if (interpolator == null) { throw new IllegalArgumentException("Missing interpolator for type : " + type); } return interpolator; }
21. DribbbleShot#enterAnimation()
Project: plaid
File: DribbbleShot.java
File: DribbbleShot.java
/** * Animate in the title, description and author – can't do this in a content transition as they * are within the ListView so do it manually. Also handle the FAB tanslation here so that it * plays nicely with #calculateFabPosition */ private void enterAnimation(boolean animateFabManually) { Interpolator interp = getFastOutSlowInInterpolator(this); int offset = title.getHeight(); viewEnterAnimation(title, offset, interp); if (description.getVisibility() == View.VISIBLE) { offset *= 1.5f; viewEnterAnimation(description, offset, interp); } // animate the fab without touching the alpha as this is handled in the content transition offset *= 1.5f; float fabTransY = fab.getTranslationY(); fab.setTranslationY(fabTransY + offset); fab.animate().translationY(fabTransY).setDuration(600).setInterpolator(interp).start(); offset *= 1.5f; viewEnterAnimation(shotActions, offset, interp); offset *= 1.5f; viewEnterAnimation(playerName, offset, interp); viewEnterAnimation(playerAvatar, offset, interp); viewEnterAnimation(shotTimeAgo, offset, interp); back.animate().alpha(1f).setDuration(600).setInterpolator(interp).start(); if (animateFabManually) { // we rely on the window enter content transition to show the fab. This isn't run on // orientation changes so manually show it. Animator showFab = ObjectAnimator.ofPropertyValuesHolder(fab, PropertyValuesHolder.ofFloat(View.ALPHA, 0f, 1f), PropertyValuesHolder.ofFloat(View.SCALE_X, 0f, 1f), PropertyValuesHolder.ofFloat(View.SCALE_Y, 0f, 1f)); showFab.setStartDelay(300L); showFab.setDuration(300L); showFab.setInterpolator(getLinearOutSlowInInterpolator(this)); showFab.start(); } }
22. ItemSlidingAnimator#slideToSpecifiedPositionInternal()
Project: PackageTracker
File: ItemSlidingAnimator.java
File: ItemSlidingAnimator.java
private boolean slideToSpecifiedPositionInternal(final RecyclerView.ViewHolder holder, final float position, boolean horizontal, boolean shouldAnimate, long duration, SwipeFinishInfo swipeFinish) { final Interpolator defaultInterpolator = mSlideToDefaultPositionAnimationInterpolator; duration = (shouldAnimate) ? duration : 0; if (position != 0.0f) { final View containerView = ((SwipeableItemViewHolder) holder).getSwipeableContainerView(); final int width = containerView.getWidth(); final int height = containerView.getHeight(); if (horizontal && width != 0) { final int translationX; translationX = (int) (width * position + 0.5f); return animateSlideInternalCompat(holder, horizontal, translationX, 0, duration, defaultInterpolator, swipeFinish); } else if (!horizontal && (height != 0)) { final int translationY; translationY = (int) (height * position + 0.5f); return animateSlideInternalCompat(holder, horizontal, 0, translationY, duration, defaultInterpolator, swipeFinish); } else { if (swipeFinish != null) { throw new IllegalStateException("Unexpected state in slideToSpecifiedPositionInternal (swipeFinish == null)"); } scheduleViewHolderDeferredSlideProcess(holder, new DeferredSlideProcess(holder, position, horizontal)); return false; } } else { return animateSlideInternalCompat(holder, horizontal, 0, 0, duration, defaultInterpolator, swipeFinish); } }
23. TreeDrawable#updateTree()
Project: FlyRefresh
File: TreeDrawable.java
File: TreeDrawable.java
public void updateTree() { final Interpolator interpolator = PathInterpolatorCompat.create(0.8f, -0.6f * mBendScale); final float width = DEFAULT_WIDTH * mSizeFactor; final float height = DEFAULT_HEIGHT * mSizeFactor; final float maxMove = width * 0.45f * mBendScale; final float trunkSize = width * 0.05f; final float branchSize = width * 0.2f; final float x0 = width / 2; final float y0 = height; mBaseLine.reset(); mBaseLine.moveTo(x0, y0); final int N = 50; final float dp = 1f / N; final float dy = -dp * height; float y = y0; float p = 0; float[] xx = new float[N + 1]; float[] yy = new float[N + 1]; for (int i = 0; i <= N; i++) { xx[i] = interpolator.getInterpolation(p) * maxMove + x0; yy[i] = y; mBaseLine.lineTo(xx[i], yy[i]); y += dy; p += dp; } mTrunk.reset(); mTrunk.moveTo(x0 - trunkSize, y0); int max = (int) (N * 0.6f); int max1 = (int) (max * 0.6f); float diff = max - max1; for (int i = 0; i < max; i++) { if (i < max1) { mTrunk.lineTo(xx[i] - trunkSize, yy[i]); } else { mTrunk.lineTo(xx[i] - trunkSize * (max - i) / diff, yy[i]); } } for (int i = max - 1; i >= 0; i--) { if (i < max1) { mTrunk.lineTo(xx[i] + trunkSize, yy[i]); } else { mTrunk.lineTo(xx[i] + trunkSize * (max - i) / diff, yy[i]); } } mTrunk.close(); mBranch.reset(); int min = (int) (N * 0.4f); diff = N - min; mBranch.addArc(new RectF(xx[min] - branchSize, yy[min] - branchSize, xx[min] + branchSize, yy[min] + branchSize), 0f, 180f); for (int i = min; i <= N; i++) { mBranch.lineTo(xx[i] + branchSize - ((i - min) / diff) * branchSize, yy[i]); } for (int i = N; i >= min; i--) { mBranch.lineTo(xx[i] - branchSize + ((i - min) / diff) * branchSize, yy[i]); } mBranch.close(); }
24. MountanScenceView#updateTreePath()
Project: FlyRefresh
File: MountanScenceView.java
File: MountanScenceView.java
private void updateTreePath(float factor, boolean force) { if (factor == mTreeBendFactor && !force) { return; } final Interpolator interpolator = PathInterpolatorCompat.create(0.8f, -0.5f * factor); final float width = TREE_WIDTH; final float height = TREE_HEIGHT; final float maxMove = width * 0.3f * factor; final float trunkSize = width * 0.05f; final float branchSize = width * 0.2f; final float x0 = width / 2; final float y0 = height; final int N = 25; final float dp = 1f / N; final float dy = -dp * height; float y = y0; float p = 0; float[] xx = new float[N + 1]; float[] yy = new float[N + 1]; for (int i = 0; i <= N; i++) { xx[i] = interpolator.getInterpolation(p) * maxMove + x0; yy[i] = y; y += dy; p += dp; } mTrunk.reset(); mTrunk.moveTo(x0 - trunkSize, y0); int max = (int) (N * 0.7f); int max1 = (int) (max * 0.5f); float diff = max - max1; for (int i = 0; i < max; i++) { if (i < max1) { mTrunk.lineTo(xx[i] - trunkSize, yy[i]); } else { mTrunk.lineTo(xx[i] - trunkSize * (max - i) / diff, yy[i]); } } for (int i = max - 1; i >= 0; i--) { if (i < max1) { mTrunk.lineTo(xx[i] + trunkSize, yy[i]); } else { mTrunk.lineTo(xx[i] + trunkSize * (max - i) / diff, yy[i]); } } mTrunk.close(); mBranch.reset(); int min = (int) (N * 0.4f); diff = N - min; mBranch.moveTo(xx[min] - branchSize, yy[min]); mBranch.addArc(new RectF(xx[min] - branchSize, yy[min] - branchSize, xx[min] + branchSize, yy[min] + branchSize), 0f, 180f); for (int i = min; i <= N; i++) { float f = (i - min) / diff; mBranch.lineTo(xx[i] - branchSize + f * f * branchSize, yy[i]); } for (int i = N; i >= min; i--) { float f = (i - min) / diff; mBranch.lineTo(xx[i] + branchSize - f * f * branchSize, yy[i]); } }
25. MountainSceneDrawable#updateTreePath()
Project: FlyRefresh
File: MountainSceneDrawable.java
File: MountainSceneDrawable.java
private void updateTreePath(float factor) { if (factor == mTreeBendFactor) { return; } final Interpolator interpolator = PathInterpolatorCompat.create(0.8f, -0.5f * factor); final float width = TREE_WIDTH; final float height = TREE_HEIGHT; final float maxMove = width * 0.3f * factor; final float trunkSize = width * 0.05f; final float branchSize = width * 0.2f; final float x0 = width / 2; final float y0 = height; final int N = 25; final float dp = 1f / N; final float dy = -dp * height; float y = y0; float p = 0; float[] xx = new float[N + 1]; float[] yy = new float[N + 1]; for (int i = 0; i <= N; i++) { xx[i] = interpolator.getInterpolation(p) * maxMove + x0; yy[i] = y; y += dy; p += dp; } mTrunk.reset(); mTrunk.moveTo(x0 - trunkSize, y0); int max = (int) (N * 0.7f); int max1 = (int) (max * 0.5f); float diff = max - max1; for (int i = 0; i < max; i++) { if (i < max1) { mTrunk.lineTo(xx[i] - trunkSize, yy[i]); } else { mTrunk.lineTo(xx[i] - trunkSize * (max - i) / diff, yy[i]); } } for (int i = max - 1; i >= 0; i--) { if (i < max1) { mTrunk.lineTo(xx[i] + trunkSize, yy[i]); } else { mTrunk.lineTo(xx[i] + trunkSize * (max - i) / diff, yy[i]); } } mTrunk.close(); mBranch.reset(); int min = (int) (N * 0.4f); diff = N - min; mBranch.moveTo(xx[min] - branchSize, yy[min]); mBranch.addArc(new RectF(xx[min] - branchSize, yy[min] - branchSize, xx[min] + branchSize, yy[min] + branchSize), 0f, 180f); for (int i = min; i <= N; i++) { float f = (i - min) / diff; mBranch.lineTo(xx[i] - branchSize + f * f * branchSize, yy[i]); } for (int i = N; i >= min; i--) { float f = (i - min) / diff; mBranch.lineTo(xx[i] + branchSize - f * f * branchSize, yy[i]); } }
26. ImageViewTouchBase#zoomTo()
Project: FlickableView
File: ImageViewTouchBase.java
File: ImageViewTouchBase.java
protected void zoomTo(float scale, float centerX, float centerY, final long durationMs) { if (scale > getMaxScale()) { scale = getMaxScale(); } final float oldScale = getScale(); Matrix m = new Matrix(mSuppMatrix); m.postScale(scale, scale, centerX, centerY); RectF rect = getCenter(m, true, true); final float finalScale = scale; final float destX = centerX + rect.left * scale; final float destY = centerY + rect.top * scale; stopAllAnimations(); ValueAnimatorCompat animatorCompat = AnimatorCompatHelper.emptyValueAnimator(); animatorCompat.setDuration(durationMs); final Interpolator interpolator = new DecelerateInterpolator(1.0f); animatorCompat.addUpdateListener(new AnimatorUpdateListenerCompat() { @Override public void onAnimationUpdate(ValueAnimatorCompat animation) { float fraction = interpolator.getInterpolation(animation.getAnimatedFraction()); float value = oldScale + (fraction * (finalScale - oldScale)); zoomTo(value, destX, destY); } }); animatorCompat.start(); }
27. ImageViewTouchBase#scrollBy()
Project: FlickableView
File: ImageViewTouchBase.java
File: ImageViewTouchBase.java
protected void scrollBy(final float distanceX, final float distanceY, final long durationMs) { ValueAnimatorCompat animatorCompat = AnimatorCompatHelper.emptyValueAnimator(); animatorCompat.setDuration(durationMs); stopAllAnimations(); mCurrentAnimation = animatorCompat; mCurrentAnimation.start(); final Interpolator interpolator = new DecelerateInterpolator(); animatorCompat.addUpdateListener(new AnimatorUpdateListenerCompat() { float oldValueX = 0; float oldValueY = 0; @Override public void onAnimationUpdate(ValueAnimatorCompat animation) { float fraction = interpolator.getInterpolation(animation.getAnimatedFraction()); float valueX = fraction * distanceX; float valueY = fraction * distanceY; panBy(valueX - oldValueX, valueY - oldValueY); oldValueX = valueX; oldValueY = valueY; } }); mCurrentAnimation.addListener(new AnimatorListenerCompat() { @Override public void onAnimationStart(ValueAnimatorCompat animation) { } @Override public void onAnimationEnd(ValueAnimatorCompat animation) { RectF centerRect = getCenter(mSuppMatrix, true, true); if (centerRect.left != 0 || centerRect.top != 0) { scrollBy(centerRect.left, centerRect.top); } } @Override public void onAnimationCancel(ValueAnimatorCompat animation) { } @Override public void onAnimationRepeat(ValueAnimatorCompat animation) { } }); }
28. FlickableImageView#snapBack()
Project: FlickableView
File: FlickableImageView.java
File: FlickableImageView.java
private void snapBack() { final float currentY = ViewCompat.getY(this); ValueAnimatorCompat animatorCompat = AnimatorCompatHelper.emptyValueAnimator(); animatorCompat.setDuration(SNAPBACK_ANIMATION_TIME); final Interpolator interpolator = new DecelerateInterpolator(); animatorCompat.addUpdateListener(new AnimatorUpdateListenerCompat() { @Override public void onAnimationUpdate(ValueAnimatorCompat animation) { float fraction = interpolator.getInterpolation(animation.getAnimatedFraction()); float interpolatedValue = currentY - (currentY * fraction); ViewCompat.setTranslationY(FlickableImageView.this, interpolatedValue); } }); animatorCompat.addListener(new AnimatorListenerCompat() { @Override public void onAnimationStart(ValueAnimatorCompat animation) { } @Override public void onAnimationEnd(ValueAnimatorCompat animation) { if (mOnDraggingListener != null) { if (mDragging) { mOnDraggingListener.onCancelDrag(); mDragging = false; } } } @Override public void onAnimationCancel(ValueAnimatorCompat animation) { } @Override public void onAnimationRepeat(ValueAnimatorCompat animation) { } }); animatorCompat.start(); }
29. ExpandableSelectorAnimator#expandContainer()
Project: ExpandableSelector
File: ExpandableSelectorAnimator.java
File: ExpandableSelectorAnimator.java
private void expandContainer(final Listener listener) { float toWidth = container.getWidth(); float toHeight = getSumHeight(); Interpolator interpolator = getContainerAnimationInterpolator(); ResizeAnimation resizeAnimation = createResizeAnimation(toWidth, interpolator, toHeight, listener); container.startAnimation(resizeAnimation); }
30. FabLayout#setSecondaryFabAnimation()
Project: EhViewer
File: FabLayout.java
File: FabLayout.java
private void setSecondaryFabAnimation(final View child, final boolean expanded, boolean delay) { float startTranslationY; float endTranslationY; float startAlpha; float endAlpha; Interpolator interpolator; if (expanded) { startTranslationY = mMainFabCenterY - (child.getTop() + (child.getHeight() / 2)); endTranslationY = 0f; startAlpha = 0f; endAlpha = 1f; interpolator = AnimationUtils.FAST_SLOW_INTERPOLATOR; } else { startTranslationY = 0f; endTranslationY = mMainFabCenterY - (child.getTop() + (child.getHeight() / 2)); startAlpha = 1f; endAlpha = 0f; interpolator = AnimationUtils.SLOW_FAST_INTERPOLATOR; } child.setAlpha(startAlpha); child.setTranslationY(startTranslationY); child.animate().alpha(endAlpha).translationY(endTranslationY).setStartDelay(delay ? ANIMATE_TIME : 0L).setDuration(ANIMATE_TIME).setInterpolator(interpolator).setListener(new SimpleAnimatorListener() { @Override public void onAnimationStart(Animator animation) { if (expanded) { child.setVisibility(View.VISIBLE); } } @Override public void onAnimationEnd(Animator animation) { if (!expanded) { child.setVisibility(View.INVISIBLE); } } }).start(); }
31. FabLayout#setPrimaryFabAnimation()
Project: EhViewer
File: FabLayout.java
File: FabLayout.java
private void setPrimaryFabAnimation(final View child, final boolean expanded, boolean delay) { float startRotation; float endRotation; float startScale; float endScale; Interpolator interpolator; if (expanded) { startRotation = -45.0f; endRotation = 0.0f; startScale = 0.0f; endScale = 1.0f; interpolator = AnimationUtils.FAST_SLOW_INTERPOLATOR; } else { startRotation = 0.0f; endRotation = 0.0f; startScale = 1.0f; endScale = 0.0f; interpolator = AnimationUtils.SLOW_FAST_INTERPOLATOR; } child.setScaleX(startScale); child.setScaleY(startScale); child.setRotation(startRotation); child.animate().scaleX(endScale).scaleY(endScale).rotation(endRotation).setStartDelay(delay ? ANIMATE_TIME : 0L).setDuration(ANIMATE_TIME).setInterpolator(interpolator).setListener(new SimpleAnimatorListener() { @Override public void onAnimationStart(Animator animation) { if (expanded) { child.setVisibility(View.VISIBLE); } } @Override public void onAnimationEnd(Animator animation) { if (!expanded) { child.setVisibility(View.INVISIBLE); } } }).start(); }
32. SampleActivity#applyDemoOptionsToClusterkrafOptions()
Project: clusterkraf
File: SampleActivity.java
File: SampleActivity.java
/** * Applies the sample.SampleActivity.Options chosen in Normal or Advanced * mode menus to the clusterkraf.Options which will be used to construct our * Clusterkraf instance * * @param options */ private void applyDemoOptionsToClusterkrafOptions(com.twotoasters.clusterkraf.Options options) { options.setTransitionDuration(this.options.transitionDuration); /** * this is probably not how you would set an interpolator in your own * app. You would probably have just one that you wanted to hard code in * your app (show me the mobile app user who actually wants to fiddle * with the interpolator used in their animations), so you would do * something more like `options.setInterpolator(new * DecelerateInterpolator());` rather than mess around with reflection. */ Interpolator interpolator = null; try { interpolator = (Interpolator) Class.forName(this.options.transitionInterpolator).newInstance(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } options.setTransitionInterpolator(interpolator); /** * Clusterkraf calculates whether InputPoint objects should join a * cluster based on their pixel proximity. If you want to offer your app * on devices with different screen densities, you should identify a * Device Independent Pixel measurement and convert it to pixels based * on the device's screen density at runtime. */ options.setPixelDistanceToJoinCluster(getPixelDistanceToJoinCluster()); options.setZoomToBoundsAnimationDuration(this.options.zoomToBoundsAnimationDuration); options.setShowInfoWindowAnimationDuration(this.options.showInfoWindowAnimationDuration); options.setExpandBoundsFactor(this.options.expandBoundsFactor); options.setSinglePointClickBehavior(this.options.singlePointClickBehavior); options.setClusterClickBehavior(this.options.clusterClickBehavior); options.setClusterInfoWindowClickBehavior(this.options.clusterInfoWindowClickBehavior); /** * Device Independent Pixel measurement should be converted to pixels * here too. In this case, we cheat a little by using a Drawable's * height. It's only cheating because we don't offer a variant for that * Drawable for every density (xxhdpi, tvdpi, others?). */ options.setZoomToBoundsPadding(getResources().getDrawable(R.drawable.ic_map_pin_cluster).getIntrinsicHeight()); options.setMarkerOptionsChooser(new ToastedMarkerOptionsChooser(this, inputPoints.get(0))); options.setOnMarkerClickDownstreamListener(new ToastedOnMarkerClickDownstreamListener(this)); options.setProcessingListener(this); }
33. FlipView#init()
Project: browser-android
File: FlipView.java
File: FlipView.java
private void init(Context context, AttributeSet attrs, int defStyle) { if (isInEditMode()) { return; } sDefaultDuration = context.getResources().getInteger(R.integer.default_fiv_duration); sDefaultRotations = context.getResources().getInteger(R.integer.default_fiv_rotations); sDefaultAnimated = context.getResources().getBoolean(R.bool.default_fiv_isAnimated); sDefaultFlipped = context.getResources().getBoolean(R.bool.default_fiv_isFlipped); sDefaultIsRotationReversed = context.getResources().getBoolean(R.bool.default_fiv_isRotationReversed); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FlipImageView, defStyle, 0); mIsDefaultAnimated = a.getBoolean(R.styleable.FlipImageView_isAnimated, sDefaultAnimated); mIsFlipped = a.getBoolean(R.styleable.FlipImageView_isFlipped, sDefaultFlipped); mDefaultView = View.inflate(getContext(), a.getResourceId(R.styleable.FlipImageView_defaultView, 0), null); mFlippedView = View.inflate(getContext(), a.getResourceId(R.styleable.FlipImageView_flipView, 0), null); int duration = a.getInt(R.styleable.FlipImageView_flipDuration, sDefaultDuration); int interpolatorResId = a.getResourceId(R.styleable.FlipImageView_flipInterpolator, 0); Interpolator interpolator = interpolatorResId > 0 ? AnimationUtils.loadInterpolator(context, interpolatorResId) : fDefaultInterpolator; int rotations = a.getInteger(R.styleable.FlipImageView_flipRotations, sDefaultRotations); mIsRotationXEnabled = (rotations & FLAG_ROTATION_X) != 0; mIsRotationYEnabled = (rotations & FLAG_ROTATION_Y) != 0; mIsRotationZEnabled = (rotations & FLAG_ROTATION_Z) != 0; mIsRotationReversed = a.getBoolean(R.styleable.FlipImageView_reverseRotation, sDefaultIsRotationReversed); mAnimation = new FlipAnimator(); mAnimation.setAnimationListener(this); mAnimation.setInterpolator(interpolator); mAnimation.setDuration(duration); setOnClickListener(this); addView(mIsFlipped ? mFlippedView : mDefaultView); mIsFlipping = false; a.recycle(); }
34. RecyclerViewSmoothScrollerActionAssert#hasInterpolator()
Project: assertj-android
File: RecyclerViewSmoothScrollerActionAssert.java
File: RecyclerViewSmoothScrollerActionAssert.java
public RecyclerViewSmoothScrollerActionAssert hasInterpolator(Interpolator interpolator) { isNotNull(); Interpolator actualInterpolator = actual.getInterpolator(); // assertThat(actualInterpolator).overridingErrorMessage("Expected interpolator <%s> but was <%s>.", interpolator, // actualInterpolator).isEqualTo(interpolator); return this; }
35. AbstractProgressBarAssert#hasInterpolator()
Project: assertj-android
File: AbstractProgressBarAssert.java
File: AbstractProgressBarAssert.java
public S hasInterpolator(Interpolator interpolator) { isNotNull(); Interpolator actualInterpolator = actual.getInterpolator(); // assertThat(actualInterpolator).overridingErrorMessage("Expected interpolator <%s> but was <%s>.", interpolator, // actualInterpolator).isSameAs(interpolator); return myself; }
36. AbstractLayoutAnimationControllerAssert#hasInterpolator()
Project: assertj-android
File: AbstractLayoutAnimationControllerAssert.java
File: AbstractLayoutAnimationControllerAssert.java
public S hasInterpolator(Interpolator interpolator) { isNotNull(); Interpolator actualInterpolator = actual.getInterpolator(); // assertThat(actualInterpolator).overridingErrorMessage("Expected interpolator <%s> but was <%s>.", interpolator, // actualInterpolator).isSameAs(interpolator); return myself; }
37. AbstractAnimationAssert#hasInterpolator()
Project: assertj-android
File: AbstractAnimationAssert.java
File: AbstractAnimationAssert.java
public S hasInterpolator(Interpolator interpolator) { isNotNull(); Interpolator actualInterpolator = actual.getInterpolator(); // assertThat(actualInterpolator).overridingErrorMessage("Expected interpolator <%s> but was <%s>.", interpolator, // actualInterpolator).isSameAs(interpolator); return myself; }
38. ItemSlidingAnimator#slideToSpecifiedPositionInternal()
Project: AppGitRoot
File: ItemSlidingAnimator.java
File: ItemSlidingAnimator.java
private boolean slideToSpecifiedPositionInternal(final RecyclerView.ViewHolder holder, final float position, boolean horizontal, boolean shouldAnimate, long duration, SwipeFinishInfo swipeFinish) { final Interpolator defaultInterpolator = mSlideToDefaultPositionAnimationInterpolator; duration = (shouldAnimate) ? duration : 0; if (position != 0.0f) { final View containerView = ((SwipeableItemViewHolder) holder).getSwipeableContainerView(); final int width = containerView.getWidth(); final int height = containerView.getHeight(); if (horizontal && width != 0) { final int translationX; translationX = (int) (width * position + 0.5f); return animateSlideInternalCompat(holder, horizontal, translationX, 0, duration, defaultInterpolator, swipeFinish); } else if (!horizontal && (height != 0)) { final int translationY; translationY = (int) (height * position + 0.5f); return animateSlideInternalCompat(holder, horizontal, 0, translationY, duration, defaultInterpolator, swipeFinish); } else { if (swipeFinish != null) { throw new IllegalStateException("Unexpected state in slideToSpecifiedPositionInternal (swipeFinish == null)"); } scheduleViewHolderDeferredSlideProcess(holder, new DeferredSlideProcess(holder, position, horizontal)); return false; } } else { return animateSlideInternalCompat(holder, horizontal, 0, 0, duration, defaultInterpolator, swipeFinish); } }
39. EBrwViewAnim#commitAnimition()
Project: appcan-android
File: EBrwViewAnim.java
File: EBrwViewAnim.java
public void commitAnimition(final EBrowserView Obj) { if (begin) { return; } begin = true; int len = animMatrix.size(); if (0 == len) { return; } Interpolator inter = new LinearInterpolator(); switch(curve) { case //??->?? BrwViewAnimaCurveEaseInOut: inter = new AccelerateDecelerateInterpolator(); break; case //?? BrwViewAnimCurveEaseIn: inter = new AccelerateInterpolator(); break; case //?? BrwViewAnimCurveEaseOut: inter = new DecelerateInterpolator(); break; case //???? BrwViewAnimCurveLinear: break; } final EBounceView target = (EBounceView) Obj.getParent(); if (null == target) { return; } AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(animMatrix); animatorSet.setDuration(duration); if (animMatrix.size() > 0) { animMatrix.get(0).addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { if (willReverse) { revertView(Obj); } Obj.loadUrl(EUExScript.F_UEX_SCRIPT_ANIMATIONEND); reset(); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); } if (delay > 0) { animatorSet.setStartDelay(delay); } animatorSet.setInterpolator(inter); animatorSet.setTarget(target); animatorSet.start(); }
40. FastCircleLoading#setUpAnimators()
Project: andrui
File: FastCircleLoading.java
File: FastCircleLoading.java
private void setUpAnimators(int duration, Interpolator pointInterpolator) { final ObjectAnimator animator = ObjectAnimator.ofFloat(this, ROTATION, 0, 720); animator.setDuration(duration); animator.setInterpolator(pointInterpolator); animator.setStartDelay(500); Interpolator interpolator = new Interpolator() { float margin = 0.3f; @Override public float getInterpolation(float input) { float interpolation; if (input < margin) { interpolation = input * 0.5f / margin; } else if (input > 1 - margin) { interpolation = 1f - (1f - input) * 0.5f / margin; } else { interpolation = 0.5f; } return interpolation; } }; final ObjectAnimator animatorX = ObjectAnimator.ofFloat(mCenterCircle, SCALE_X, 1f, 0f, 1f); animatorX.setDuration(duration); animatorX.setInterpolator(interpolator); final ObjectAnimator animatorY = ObjectAnimator.ofFloat(mCenterCircle, SCALE_Y, 1f, 0f, 1f); animatorY.setDuration(duration); animatorY.setInterpolator(interpolator); mCircleAnimator = new AnimatorSet(); mCircleAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); mCircleAnimator.setStartDelay(500); mCircleAnimator.start(); } }); mCircleAnimator.playTogether(animator, animatorX, animatorY); }
41. CircleLoading#createCircleAnimation()
Project: andrui
File: CircleLoading.java
File: CircleLoading.java
private AnimatorSet createCircleAnimation(ImageView circle, boolean outer) { Interpolator interpolator = new AccelerateDecelerateInterpolator(); ObjectAnimator animatorX1 = ObjectAnimator.ofFloat(circle, View.SCALE_X, outer ? 1f : 0.7f, outer ? 0.7f : 1f); ObjectAnimator animatorY1 = ObjectAnimator.ofFloat(circle, View.SCALE_Y, outer ? 1f : 0.7f, outer ? 0.7f : 1f); animatorX1.setInterpolator(interpolator); animatorY1.setInterpolator(interpolator); ObjectAnimator animatorX2 = ObjectAnimator.ofFloat(circle, View.SCALE_X, outer ? 0.7f : 1f, outer ? 1f : 0.7f); ObjectAnimator animatorY2 = ObjectAnimator.ofFloat(circle, View.SCALE_Y, outer ? 0.7f : 1f, outer ? 1f : 0.7f); animatorX2.setInterpolator(interpolator); animatorY2.setInterpolator(interpolator); AnimatorSet animatorSet1 = new AnimatorSet(); animatorSet1.playTogether(animatorX1, animatorY1); AnimatorSet animatorSet2 = new AnimatorSet(); animatorSet2.playTogether(animatorX2, animatorY2); final AnimatorSet finalAnimatorSet = new AnimatorSet(); finalAnimatorSet.playSequentially(animatorSet1, animatorSet2); return finalAnimatorSet; }
42. CustomListView#initPullImageAnimation()
Project: AndroidStudyDemo
File: CustomListView.java
File: CustomListView.java
/** * ??????????????? * @param pAnimDuration ?????? * @date 2013-11-20 ??11:53:22 * @change JohnWatson * @version 1.0 */ private void initPullImageAnimation(final int pAnimDuration) { int _Duration; if (pAnimDuration > 0) { _Duration = pAnimDuration; } else { _Duration = 250; } // Interpolator _Interpolator; // switch (pAnimType) { // case 0: // _Interpolator = new AccelerateDecelerateInterpolator(); // break; // case 1: // _Interpolator = new AccelerateInterpolator(); // break; // case 2: // _Interpolator = new AnticipateInterpolator(); // break; // case 3: // _Interpolator = new AnticipateOvershootInterpolator(); // break; // case 4: // _Interpolator = new BounceInterpolator(); // break; // case 5: // _Interpolator = new CycleInterpolator(1f); // break; // case 6: // _Interpolator = new DecelerateInterpolator(); // break; // case 7: // _Interpolator = new OvershootInterpolator(); // break; // default: // _Interpolator = new LinearInterpolator(); // break; // } Interpolator _Interpolator = new LinearInterpolator(); mArrowAnim = new RotateAnimation(0, -180, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f); mArrowAnim.setInterpolator(_Interpolator); mArrowAnim.setDuration(_Duration); mArrowAnim.setFillAfter(true); mArrowReverseAnim = new RotateAnimation(-180, 0, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f); mArrowReverseAnim.setInterpolator(_Interpolator); mArrowReverseAnim.setDuration(_Duration); mArrowReverseAnim.setFillAfter(true); }
43. VisibleRegionDemoActivity#animatePadding()
Project: android-samples
File: VisibleRegionDemoActivity.java
File: VisibleRegionDemoActivity.java
public void animatePadding(final int toLeft, final int toTop, final int toRight, final int toBottom) { final Handler handler = new Handler(); final long start = SystemClock.uptimeMillis(); final long duration = 1000; final Interpolator interpolator = new OvershootInterpolator(); final int startLeft = currentLeft; final int startTop = currentTop; final int startRight = currentRight; final int startBottom = currentBottom; currentLeft = toLeft; currentTop = toTop; currentRight = toRight; currentBottom = toBottom; handler.post(new Runnable() { @Override public void run() { long elapsed = SystemClock.uptimeMillis() - start; float t = interpolator.getInterpolation((float) elapsed / duration); int left = (int) (startLeft + ((toLeft - startLeft) * t)); int top = (int) (startTop + ((toTop - startTop) * t)); int right = (int) (startRight + ((toRight - startRight) * t)); int bottom = (int) (startBottom + ((toBottom - startBottom) * t)); mMap.setPadding(left, top, right, bottom); if (elapsed < duration) { // Post again 16ms later. handler.postDelayed(this, 16); } } }); }
44. ChartSeries#startAnimateEffect()
Project: android-DecoView-charting
File: ChartSeries.java
File: ChartSeries.java
/** * Execute an Animation effect by starting the Value Animator * * @param event Event to process effect * @throws IllegalStateException No effect set in event */ public void startAnimateEffect(@NonNull final DecoEvent event) throws IllegalStateException { if (event.getEffectType() == null) { throw new IllegalStateException("Unable to execute null effect type"); } // All effects run from 0.0 .. 1.0f in duration final float maxValue = 1.0f; cancelAnimation(); event.notifyStartListener(); mVisible = true; mDrawMode = event.getEventType(); mEffect = new DecoDrawEffect(event.getEffectType(), mPaint, event.getDisplayText()); mEffect.setRotationCount(event.getEffectRotations()); mPercentComplete = 0f; mValueAnimator = ValueAnimator.ofFloat(0, maxValue); mValueAnimator.setDuration(event.getEffectDuration()); Interpolator interpolator = (event.getInterpolator() != null) ? event.getInterpolator() : new LinearInterpolator(); mValueAnimator.setInterpolator(interpolator); mValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { mPercentComplete = Float.valueOf(valueAnimator.getAnimatedValue().toString()); for (SeriesItem.SeriesItemListener seriesItemListener : mSeriesItem.getListeners()) { seriesItemListener.onSeriesItemDisplayProgress(mPercentComplete); } } }); mValueAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { event.notifyEndListener(); mDrawMode = DecoEvent.EventType.EVENT_MOVE; mVisible = mEffect.postExecuteVisibility(); mEffect = null; } }); mValueAnimator.start(); }
45. ItemSlidingAnimator#slideToSpecifiedPositionInternal()
Project: android-advancedrecyclerview
File: ItemSlidingAnimator.java
File: ItemSlidingAnimator.java
private boolean slideToSpecifiedPositionInternal(final RecyclerView.ViewHolder holder, final float position, boolean horizontal, boolean shouldAnimate, long duration, SwipeFinishInfo swipeFinish) { final Interpolator defaultInterpolator = mSlideToDefaultPositionAnimationInterpolator; duration = (shouldAnimate) ? duration : 0; if (position != 0.0f) { final View containerView = ((SwipeableItemViewHolder) holder).getSwipeableContainerView(); final int width = containerView.getWidth(); final int height = containerView.getHeight(); if (horizontal && width != 0) { final int translationX; translationX = (int) (width * position + 0.5f); return animateSlideInternalCompat(holder, horizontal, translationX, 0, duration, defaultInterpolator, swipeFinish); } else if (!horizontal && (height != 0)) { final int translationY; translationY = (int) (height * position + 0.5f); return animateSlideInternalCompat(holder, horizontal, 0, translationY, duration, defaultInterpolator, swipeFinish); } else { if (swipeFinish != null) { throw new IllegalStateException("Unexpected state in slideToSpecifiedPositionInternal (swipeFinish == null)"); } scheduleViewHolderDeferredSlideProcess(holder, new DeferredSlideProcess(holder, position, horizontal)); return false; } } else { return animateSlideInternalCompat(holder, horizontal, 0, 0, duration, defaultInterpolator, swipeFinish); } }