/** * Starts a peek animation to add a specific tab. * * @param item * The item, which corresponds to the tab, which should be added, as an instance of the * class {@link AbstractItem}. The item may not be null * @param duration * The duration of the animation in milliseconds as a {@link Long} value * @param interpolator * The interpolator, which should be used by the animation, as an instance of the type * {@link Interpolator}. The interpolator may not be null * @param peekPosition * The position on the dragging axis, the tab should be moved to, in pixels as a {@link * Float} value * @param peekAnimation * The peek animation, which has been used to add the tab, as an instance of the class * {@link PeekAnimation}. The peek animation may not be null */ private void animatePeek(@NonNull final AbstractItem item, final long duration, @NonNull final Interpolator interpolator, final float peekPosition, @NonNull final PeekAnimation peekAnimation) { PhoneTabViewHolder viewHolder = (PhoneTabViewHolder) ((TabItem) item).getViewHolder(); viewHolder.closeButton.setVisibility(View.GONE); View view = item.getView(); float x = peekAnimation.getX(); float y = peekAnimation.getY() + tabTitleContainerHeight; FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams(); view.setAlpha(1f); getArithmetics().setPivot(Axis.X_AXIS, item, x); getArithmetics().setPivot(Axis.Y_AXIS, item, y); view.setX(layoutParams.leftMargin); view.setY(layoutParams.topMargin); getArithmetics().setScale(Axis.DRAGGING_AXIS, item, 0); getArithmetics().setScale(Axis.ORTHOGONAL_AXIS, item, 0); ViewPropertyAnimator animation = view.animate(); animation.setInterpolator(interpolator); animation.setListener( new AnimationListenerWrapper(createPeekAnimationListener(item, peekAnimation))); animation.setStartDelay(0); animation.setDuration(duration); getArithmetics().animateScale(Axis.DRAGGING_AXIS, animation, 1); getArithmetics().animateScale(Axis.ORTHOGONAL_AXIS, animation, 1); getArithmetics().animatePosition(Axis.DRAGGING_AXIS, animation, item, peekPosition, true); animation.start(); int selectedTabIndex = getModel().getSelectedTabIndex(); TabItem selectedItem = TabItem.create(getModel(), tabViewRecycler, selectedTabIndex); tabViewRecycler.inflate(selectedItem); selectedItem.getTag().setPosition(0); PhoneTabViewHolder selectedTabViewHolder = (PhoneTabViewHolder) selectedItem.getViewHolder(); selectedTabViewHolder.closeButton.setVisibility(View.GONE); animateShowSwitcher(selectedItem, duration, interpolator, createZoomOutAnimationListener(selectedItem, peekAnimation)); }
/** * Creates and returns a layout listener, which allows to start a peek animation to add a tab, * once its view has been inflated. * * @param tabItem * The tab item, which corresponds to the tab, which should be added, as an instance of * the class {@link TabItem}. The tab item may not be null * @param peekAnimation * The peek animation, which should be started, 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 * OnGlobalLayoutListener}. The listener may not be null */ private OnGlobalLayoutListener createPeekLayoutListener(@NonNull final TabItem tabItem, @NonNull final PeekAnimation peekAnimation) { return new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { long totalDuration = peekAnimation.getDuration() != -1 ? peekAnimation.getDuration() : peekAnimationDuration; long duration = totalDuration / 3; Interpolator interpolator = peekAnimation.getInterpolator() != null ? peekAnimation.getInterpolator() : new AccelerateDecelerateInterpolator(); float peekPosition = getArithmetics().getTabContainerSize(Axis.DRAGGING_AXIS, false) * 0.66f; animatePeek(tabItem, duration, interpolator, peekPosition, peekAnimation); } }; }
private void initSwitchSpeed(float scrollFactor) { try { Class<?> viewpager = ViewPager.class; Field scroller = viewpager.getDeclaredField("mScroller"); scroller.setAccessible(true); Field interpolator = viewpager.getDeclaredField("sInterpolator"); interpolator.setAccessible(true); mScroller = new ScrollerCustomDuration(getContext(), (Interpolator) interpolator.get(null)); mScroller.setScrollFactor(scrollFactor); scroller.set(this, mScroller); } catch (Exception e) { } }
public void setupSharedEelementTransitions() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) return; //Show dialog normally if below Lollipop ArcMotion arcMotion = new ArcMotion(); arcMotion.setMinimumHorizontalAngle(50f); arcMotion.setMinimumVerticalAngle(50f); Interpolator easeInOut = AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in); MorphFabToDialog sharedEnter = new MorphFabToDialog(getBackgroundColor()); sharedEnter.setPathMotion(arcMotion); sharedEnter.setInterpolator(easeInOut); MorphDialogToFab sharedReturn = new MorphDialogToFab(getBackgroundColor()); sharedReturn.setPathMotion(arcMotion); sharedReturn.setInterpolator(easeInOut); if (ui.container != null) { sharedEnter.addTarget(ui.container); sharedReturn.addTarget(ui.container); } getWindow().setSharedElementEnterTransition(sharedEnter); getWindow().setSharedElementReturnTransition(sharedReturn); }
/** * Override the Scroller instance with our own class so we can change the * duration */ private void postInitViewPager() { if (isInEditMode()) { return; } try { Field scroller = ViewPager.class.getDeclaredField("mScroller"); scroller.setAccessible(true); Field interpolator = ViewPager.class .getDeclaredField("sInterpolator"); interpolator.setAccessible(true); mScroller = new WXSmoothScroller(getContext(), (Interpolator) interpolator.get(null)); scroller.set(this, mScroller); } catch (Exception e) { WXLogUtils.e("[CircleViewPager] postInitViewPager: ", e); } }
/** * Create a Scroller with the specified interpolator. If the interpolator is * null, the default (viscous) interpolator will be used. Specify whether or * not to support progressive "flywheel" behavior in flinging. */ public Scroller(Context context, Interpolator interpolator, boolean flywheel) { mFinished = true; mInterpolator = interpolator; mPpi = context.getResources().getDisplayMetrics().density * 160.0f; mDeceleration = computeDeceleration(ViewConfiguration.getScrollFriction()); mFlywheel = flywheel; }
/** * Animates the position and size of a specific tab in order to show the tab switcher. * * @param tabItem * The tab item, which should be animated, as an instance of the class {@link TabItem}. * The tab item may not be null * @param duration * The duration of the animation in milliseconds as a {@link Long} value * @param interpolator * The interpolator, which should be used by the animation, as an instance of the type * {@link Interpolator}. The interpolator may not be null * @param listener * The listener, which should be notified about the animation's progress, as an instance * of the type {@link AnimatorListener} or null, if no listener should be notified */ private void animateShowSwitcher(@NonNull final TabItem tabItem, final long duration, @NonNull final Interpolator interpolator, @Nullable final AnimatorListener listener) { View view = tabItem.getView(); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams(); view.setX(layoutParams.leftMargin); view.setY(layoutParams.topMargin); getArithmetics().setScale(Axis.DRAGGING_AXIS, view, 1); getArithmetics().setScale(Axis.ORTHOGONAL_AXIS, view, 1); getArithmetics().setPivot(Axis.DRAGGING_AXIS, view, getArithmetics().getPivot(Axis.DRAGGING_AXIS, view, DragState.NONE)); getArithmetics().setPivot(Axis.ORTHOGONAL_AXIS, view, getArithmetics().getPivot(Axis.ORTHOGONAL_AXIS, view, DragState.NONE)); float scale = getArithmetics().getScale(view, true); int selectedTabIndex = getModel().getSelectedTabIndex(); if (tabItem.getIndex() < selectedTabIndex) { getArithmetics().setPosition(Axis.DRAGGING_AXIS, view, getArithmetics().getTabContainerSize(Axis.DRAGGING_AXIS)); } else if (tabItem.getIndex() > selectedTabIndex) { getArithmetics().setPosition(Axis.DRAGGING_AXIS, view, getTabSwitcher().getLayout() == Layout.PHONE_LANDSCAPE ? 0 : layoutParams.topMargin); } if (tabViewBottomMargin == -1) { tabViewBottomMargin = calculateBottomMargin(view); } animateBottomMargin(view, tabViewBottomMargin, duration, 0); ViewPropertyAnimator animation = view.animate(); animation.setDuration(duration); animation.setInterpolator(interpolator); animation.setListener(new AnimationListenerWrapper(listener)); getArithmetics().animateScale(Axis.DRAGGING_AXIS, animation, scale); getArithmetics().animateScale(Axis.ORTHOGONAL_AXIS, animation, scale); getArithmetics().animatePosition(Axis.DRAGGING_AXIS, animation, view, tabItem.getTag().getPosition(), true); getArithmetics().animatePosition(Axis.ORTHOGONAL_AXIS, animation, view, 0, true); animation.setStartDelay(0); animation.start(); }
public CanvasTransformer zoom(final int openedX, final int closedX, final int openedY, final int closedY, final int px, final int py, final Interpolator interp) { initTransformer(); mTrans = new CanvasTransformer() { public void transformCanvas(Canvas canvas, float percentOpen) { mTrans.transformCanvas(canvas, percentOpen); float f = interp.getInterpolation(percentOpen); canvas.scale((openedX - closedX) * f + closedX, (openedY - closedY) * f + closedY, px, py); } }; return mTrans; }
public void smoothScrollBy(int dx, int dy, int duration, Interpolator interpolator) { if (mInterpolator != interpolator) { mInterpolator = interpolator; mScroller = ScrollerCompat.create(getContext(), interpolator); } setScrollState(SCROLL_STATE_SETTLING); mLastFlingX = mLastFlingY = 0; mScroller.startScroll(0, 0, dx, dy, duration); postOnAnimation(); }
public Morpho reverse(AnimationType type, int duration, Interpolator interpolator) { boolean animationPartsIsConfigured = this.animationParts != null && this.animationParts.size() > 0; boolean coreViewIsInitialized = this.viewToMorph != null && this.viewDefault != null; boolean animationIsNotRunning = this.completeAnimation != null && !this.completeAnimation.isRunning(); if (animationPartsIsConfigured && coreViewIsInitialized && animationIsNotRunning) { this.completeAnimation = new AnimatorSet(); ArrayList<Animation> reversedAnimationParts = new ArrayList<>(); reversedAnimationParts.addAll(animationParts); Collections.reverse(reversedAnimationParts); ArrayList<Animator> animators = new ArrayList<>(); for (Animation a : reversedAnimationParts) { animators.add(a.buildAnimation(this.viewDefault, this.viewToMorph, true)); } // Type of Animation if (type == AnimationType.SEQUENTIAL) { this.completeAnimation.playSequentially(animators); } else { this.completeAnimation.playTogether(animators); } // Duration if (duration >= 0) { this.completeAnimation.setDuration(duration); } // Interpolator if (interpolator != null) { this.completeAnimation.setInterpolator(interpolator); } this.completeAnimation.start(); this.completeAnimation = null; } return this; }
public static void startAnimation(WXSDKInstance mWXSDKInstance, WXComponent component, @NonNull WXAnimationBean animationBean, @Nullable String callback) { if(component == null){ return; } if (component.getHostView() == null) { AnimationHolder holder = new AnimationHolder(animationBean, callback); component.postAnimation(holder); return; } try { Animator animator = createAnimator(animationBean, component.getHostView(),mWXSDKInstance.getViewPortWidth()); if (animator != null) { Animator.AnimatorListener animatorCallback = createAnimatorListener(mWXSDKInstance, callback); if(Build.VERSION.SDK_INT<Build.VERSION_CODES.JELLY_BEAN_MR2) { component.getHostView().setLayerType(View.LAYER_TYPE_HARDWARE, null); } Interpolator interpolator = createTimeInterpolator(animationBean); if (animatorCallback != null) { animator.addListener(animatorCallback); } if (interpolator != null) { animator.setInterpolator(interpolator); } animator.setDuration(animationBean.duration); animator.start(); } } catch (RuntimeException e) { e.printStackTrace(); WXLogUtils.e("", e); } }
/** * Animates the position and size of a specific tab in order to show the tab switcher. * * @param item * The item, which corresponds to the tab, which should be animated, as an instance of * the class {@link AbstractItem}. The item may not be null * @param duration * The duration of the animation in milliseconds as a {@link Long} value * @param interpolator * The interpolator, which should be used by the animation, as an instance of the type * {@link Interpolator}. The interpolator may not be null * @param listener * The listener, which should be notified about the animation's progress, as an instance * of the type {@link AnimatorListener} or null, if no listener should be notified */ private void animateShowSwitcher(@NonNull final AbstractItem item, final long duration, @NonNull final Interpolator interpolator, @Nullable final AnimatorListener listener) { View view = item.getView(); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams(); view.setX(layoutParams.leftMargin); view.setY(layoutParams.topMargin); getArithmetics().setScale(Axis.DRAGGING_AXIS, item, 1); getArithmetics().setScale(Axis.ORTHOGONAL_AXIS, item, 1); getArithmetics().setPivot(Axis.DRAGGING_AXIS, item, getArithmetics().getPivot(Axis.DRAGGING_AXIS, item, DragState.NONE)); getArithmetics().setPivot(Axis.ORTHOGONAL_AXIS, item, getArithmetics().getPivot(Axis.ORTHOGONAL_AXIS, item, DragState.NONE)); float scale = getArithmetics().getScale(item, true); int selectedTabIndex = getModel().getSelectedTabIndex(); if (item.getIndex() < selectedTabIndex) { getArithmetics().setPosition(Axis.DRAGGING_AXIS, item, getArithmetics().getTabContainerSize(Axis.DRAGGING_AXIS)); } else if (item.getIndex() > selectedTabIndex) { getArithmetics().setPosition(Axis.DRAGGING_AXIS, item, getTabSwitcher().getLayout() == Layout.PHONE_LANDSCAPE ? 0 : layoutParams.topMargin); } if (tabViewBottomMargin == -1) { tabViewBottomMargin = calculateBottomMargin(item); } animateBottomMargin(view, tabViewBottomMargin, duration, 0); ViewPropertyAnimator animation = view.animate(); animation.setDuration(duration); animation.setInterpolator(interpolator); animation.setListener(new AnimationListenerWrapper(listener)); getArithmetics().animateScale(Axis.DRAGGING_AXIS, animation, scale); getArithmetics().animateScale(Axis.ORTHOGONAL_AXIS, animation, scale); getArithmetics() .animatePosition(Axis.DRAGGING_AXIS, animation, item, item.getTag().getPosition(), true); getArithmetics().animatePosition(Axis.ORTHOGONAL_AXIS, animation, item, 0, true); animation.setStartDelay(0); animation.start(); }
public static Interpolator getFastOutSlowInInterpolator(Context context) { if (fastOutSlowIn == null) { fastOutSlowIn = AnimationUtils.loadInterpolator(context, android.R.interpolator.fast_out_slow_in); } return fastOutSlowIn; }
public static Interpolator parse(Integer type, Float cycles) { if (type != null) { switch (type) { case 0: return new AccelerateDecelerateInterpolator(); case 1: return new AccelerateInterpolator(); case 2: return new AnticipateInterpolator(); case 3: return new AnticipateOvershootInterpolator(); case 4: return new BounceInterpolator(); case 5: return new CycleInterpolator((cycles != null && cycles > 0) ? cycles : 1f); case 6: return new DecelerateInterpolator(); case 7: return new LinearInterpolator(); case 8: return new OvershootInterpolator(); //暂时不支持的 // case 7: return new FastOutLinearInterplator(); // case 8: return new FastOutSlowInInterplator(); // case 10: return new LinearOutSlowInInterplator(); // case 12: return new PathInterplator(); default: return new LinearInterpolator(); } } else { return new LinearInterpolator(); } }
public AllAppsCaretController(CaretDrawable caret, Launcher launcher) { mLauncher = launcher; mCaretDrawable = caret; final long caretAnimationDuration = launcher.getResources().getInteger( R.integer.config_caretAnimationDuration); final Interpolator caretInterpolator = AnimationUtils.loadInterpolator(launcher, android.R.interpolator.fast_out_slow_in); // We will set values later mCaretAnimator = ObjectAnimator.ofFloat(mCaretDrawable, "caretProgress", 0); mCaretAnimator.setDuration(caretAnimationDuration); mCaretAnimator.setInterpolator(caretInterpolator); }
public static Interpolator getFastOutLinearInInterpolator(Context context) { if (fastOutLinearIn == null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { fastOutLinearIn = AnimationUtils.loadInterpolator(context, android.R.interpolator.fast_out_linear_in); } } return fastOutLinearIn; }
@Override public void setInterpolator(Interpolator value) { Animator a = mAnimator.get(); if (a != null) { a.setInterpolator(value); } }
public CanvasTransformer translate(final int openedX, final int closedX, final int openedY, final int closedY, final Interpolator interp) { initTransformer(); mTrans = new CanvasTransformer() { public void transformCanvas(Canvas canvas, float percentOpen) { mTrans.transformCanvas(canvas, percentOpen); float f = interp.getInterpolation(percentOpen); canvas.translate((openedX - closedX) * f + closedX, (openedY - closedY) * f + closedY); } }; return mTrans; }
public IndicatorLayout(Context context, PullToRefreshBase.Mode mode) { super(context); mArrowImageView = new ImageView(context); Drawable arrowD = getResources().getDrawable(R.drawable.indicator_arrow); mArrowImageView.setImageDrawable(arrowD); final int padding = getResources().getDimensionPixelSize(R.dimen.indicator_internal_padding); mArrowImageView.setPadding(padding, padding, padding, padding); addView(mArrowImageView); int inAnimResId, outAnimResId; switch (mode) { case PULL_FROM_END: inAnimResId = R.anim.slide_in_from_bottom; outAnimResId = R.anim.slide_out_to_bottom; setBackgroundResource(R.drawable.indicator_bg_bottom); // Rotate Arrow so it's pointing the correct way mArrowImageView.setScaleType(ScaleType.MATRIX); Matrix matrix = new Matrix(); matrix.setRotate(180f, arrowD.getIntrinsicWidth() / 2f, arrowD.getIntrinsicHeight() / 2f); mArrowImageView.setImageMatrix(matrix); break; default: case PULL_FROM_START: inAnimResId = R.anim.slide_in_from_top; outAnimResId = R.anim.slide_out_to_top; setBackgroundResource(R.drawable.indicator_bg_top); break; } mInAnim = AnimationUtils.loadAnimation(context, inAnimResId); mInAnim.setAnimationListener(this); mOutAnim = AnimationUtils.loadAnimation(context, outAnimResId); mOutAnim.setAnimationListener(this); final Interpolator interpolator = new LinearInterpolator(); mRotateAnimation = new RotateAnimation(0, -180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); mRotateAnimation.setInterpolator(interpolator); mRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION); mRotateAnimation.setFillAfter(true); mResetRotateAnimation = new RotateAnimation(-180, 0, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); mResetRotateAnimation.setInterpolator(interpolator); mResetRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION); mResetRotateAnimation.setFillAfter(true); }
private static float lerp(float startValue, float endValue, float fraction, Interpolator interpolator) { if (interpolator != null) { fraction = interpolator.getInterpolation(fraction); } return AnimationUtils.lerp(startValue, endValue, fraction); }
public ShiftDrawable(@NonNull Drawable d, int duration, @Nullable Interpolator interpolator) { super(d); mAnimator.setDuration(duration); mAnimator.setRepeatCount(ValueAnimator.INFINITE); mAnimator.setInterpolator((interpolator == null) ? new LinearInterpolator() : interpolator); mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { if (isVisible()) { invalidateSelf(); } } }); mAnimator.start(); }
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) static Interpolator getFastOutSlowInInterpolator(Context context) { if (fastOutSlowIn == null) { fastOutSlowIn = AnimationUtils.loadInterpolator(context, android.R.interpolator.fast_out_slow_in); } return fastOutSlowIn; }
public BannerScroller(Context context, Interpolator interpolator, boolean flywheel) { super(context, interpolator, flywheel); }
public Morpho translationZ(AnimationTarget target, float valueZ, int duration, Interpolator interpolator) { animationParts.add(new AxisTranslationAnimation(Axis.Z, target, valueZ, duration, interpolator)); return this; }
private static Interpolator defaultInterpolator() { return new AccelerateDecelerateInterpolator(); }
private Interpolator getInterpolator() { return AnimationUtils.loadInterpolator(getContext(), R.interpolator.msf_interpolator); }
public void setScaleInterpolator(Interpolator scaleInterpolator) { mScaleInterpolator = scaleInterpolator; }
public void setPositionInterpolator(Interpolator interpolator) { mPositionInterpolator = interpolator; recalculate(); }
public ScrollerCustomDuration(Context context, Interpolator interpolator) { super(context, interpolator); }
@Override public void setScrollBackInterpolator(Interpolator interpolator) { mAViewParams.mScrollBackAnimInterpolator = interpolator; }
public void setIconAnimationOpenInterpolator(Interpolator openInterpolator) { mOpenAnimatorSet.setInterpolator(openInterpolator); }
public static Interpolator create(Path path) { if (VERSION.SDK_INT >= 21) { return PathInterpolatorCompatApi21.create(path); } return PathInterpolatorCompatBase.create(path); }
void setInterpolator(Interpolator interpolator) { mInterpolator = interpolator; }
public ExpectAnim setInterpolator(@NonNull Interpolator interpolator) { this.interpolator = interpolator; return this; }
public void setInterpolator(Interpolator interpolator) { Iterator i$ = this.mNodes.iterator(); while (i$.hasNext()) { ((Node) i$.next()).animation.setInterpolator(interpolator); } }
public AnimationComposer interpolate(Interpolator interpolator) { this.interpolator = interpolator; return this; }
public SlideInUpAnimator(Interpolator interpolator) { mInterpolator = interpolator; }
public Interpolator getInterpolator() { return interpolator; }
/** * 设置回弹显示插值器 */ @Override public SmartRefreshLayout setReboundInterpolator(Interpolator interpolator) { this.mReboundInterpolator = interpolator; return this; }