android.support.v4.view.animation.FastOutSlowInInterpolator Java Examples

The following examples show how to use android.support.v4.view.animation.FastOutSlowInInterpolator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChatActivity.java    From talk-android with MIT License 6 votes vote down vote up
public void resetStory() {
    getSupportActionBar().setTitle(story.getTitle());
    overlay.setClickable(false);
    overlay.animate()
            .alpha(0.0F)
            .setDuration(200L)
            .setInterpolator(new FastOutSlowInInterpolator())
            .start();
    switch (StoryDataProcess.Category.getEnum(story.getCategory())) {
        case FILE:
            getSupportFragmentManager().beginTransaction()
                    .replace(R.id.container, FileStoryFragment.getInstance(story, false))
                    .commit();
            break;
        case TOPIC:
            getSupportFragmentManager().beginTransaction()
                    .replace(R.id.container, TopicStoryFragment.getInstance(story, false))
                    .commit();
            break;
        case LINK:
            getSupportFragmentManager().beginTransaction()
                    .replace(R.id.container, LinkStoryFragment.getInstance(story, false))
                    .commit();
            break;
    }
}
 
Example #2
Source File: Case3Scene.java    From scene with Apache License 2.0 6 votes vote down vote up
@NonNull
@Override
protected Animator onPushAnimator(AnimationInfo from, final AnimationInfo to) {
    final View fromView = from.mSceneView;
    final View toView = to.mSceneView;

    ValueAnimator fromAlphaAnimator = ObjectAnimator.ofFloat(fromView, View.ALPHA, 1.0f, 1.0f);//之前是0.7,但是动画后面会露出NavigationScene的背景色白色很怪异
    fromAlphaAnimator.setInterpolator(new FastOutSlowInInterpolator());
    fromAlphaAnimator.setDuration(120 * 20);

    ValueAnimator toAlphaAnimator = ObjectAnimator.ofFloat(toView, View.ALPHA, 0.0f, 1.0f);
    toAlphaAnimator.setInterpolator(new DecelerateInterpolator(2));
    toAlphaAnimator.setDuration(120 * 20);

    ValueAnimator toTranslateAnimator = ObjectAnimator.ofFloat(toView, View.TRANSLATION_Y, 0.08f * toView.getHeight(), 0);
    toTranslateAnimator.setInterpolator(new DecelerateInterpolator(2.5f));
    toTranslateAnimator.setDuration(200 * 20);
    return TransitionUtils.mergeAnimators(fromAlphaAnimator, toAlphaAnimator, toTranslateAnimator);
}
 
Example #3
Source File: ScrollScaleAnimator.java    From YCDialog with Apache License 2.0 6 votes vote down vote up
@Override
public void animateDismiss() {
    ValueAnimator animator = ValueAnimator.ofFloat(0, 1);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float fraction = animation.getAnimatedFraction();
            targetView.setAlpha(floatEvaluator.evaluate(fraction, 1f, startAlpha));
            targetView.scrollTo(intEvaluator.evaluate(fraction, 0, startScrollX),
                    intEvaluator.evaluate(fraction, 0, startScrollY));
            float scale = floatEvaluator.evaluate(fraction, 1f, startScale);
            targetView.setScaleX(scale);
            if(!isOnlyScaleX)targetView.setScaleY(scale);
            if(targetView.getBackground()!=null)targetView.getBackground().setAlpha((int) (fraction*255));
        }
    });
    animator.setDuration(animationDuration)
            .setInterpolator(new FastOutSlowInInterpolator());
    animator.start();
}
 
Example #4
Source File: ScaleTouchListener.java    From ScaleTouchListener with Apache License 2.0 6 votes vote down vote up
private void createAnimators() {
    alphaDownAnimator = ObjectAnimator.ofFloat(mView.get(), "alpha", config.getAlpha());
    alphaUpAnimator = ObjectAnimator.ofFloat(mView.get(), "alpha", 1.0f);
    scaleXDownAnimator = ObjectAnimator.ofFloat(mView.get(), "scaleX", config.getScaleDown());
    scaleXUpAnimator = ObjectAnimator.ofFloat(mView.get(), "scaleX", 1.0f);
    scaleYDownAnimator = ObjectAnimator.ofFloat(mView.get(), "scaleY", config.getScaleDown());
    scaleYUpAnimator = ObjectAnimator.ofFloat(mView.get(), "scaleY", 1.0f);

    downSet = new AnimatorSet();
    downSet.setDuration(config.getDuration());
    downSet.setInterpolator(new AccelerateInterpolator());
    downSet.playTogether(alphaDownAnimator, scaleXDownAnimator, scaleYDownAnimator);

    upSet = new AnimatorSet();
    upSet.setDuration(config.getDuration());
    upSet.setInterpolator(new FastOutSlowInInterpolator());
    upSet.playTogether(alphaUpAnimator, scaleXUpAnimator, scaleYUpAnimator);

    finalAnimationListener = new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            onClick(mView.get());
        }
    };
}
 
Example #5
Source File: ScrollScaleAnimator.java    From YCDialog with Apache License 2.0 6 votes vote down vote up
@Override
public void animateShow() {
    ValueAnimator animator = ValueAnimator.ofFloat(0, 1);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float fraction = animation.getAnimatedFraction();
            targetView.setAlpha(floatEvaluator.evaluate(fraction, startAlpha, 1f));
            targetView.scrollTo(intEvaluator.evaluate(fraction, startScrollX, 0),
                    intEvaluator.evaluate(fraction, startScrollY, 0));
            float scale = floatEvaluator.evaluate(fraction, startScale, 1f);
            targetView.setScaleX(scale);
            if(!isOnlyScaleX)targetView.setScaleY(scale);
            if(fraction>=.9f && targetView.getBackground()!=null) {
                float alphaFraction = (fraction - .9f) / .1f;
                targetView.getBackground().setAlpha((int) (alphaFraction*255));
            }
        }
    });
    animator.setDuration(animationDuration)
            .setInterpolator(new FastOutSlowInInterpolator());
    animator.start();
}
 
Example #6
Source File: TranslateAnimator.java    From YCDialog with Apache License 2.0 6 votes vote down vote up
@Override
public void animateDismiss() {
    //执行消失动画的时候,宽高可能改变了,所以需要修正动画的起始值
    switch (popupAnimation) {
        case TranslateFromLeft:
            startTranslationX -= targetView.getMeasuredWidth() - oldWidth;
            break;
        case TranslateFromTop:
            startTranslationY -= targetView.getMeasuredHeight() - oldHeight;
            break;
        case TranslateFromRight:
            startTranslationX += targetView.getMeasuredWidth() - oldWidth;
            break;
        case TranslateFromBottom:
            startTranslationY += targetView.getMeasuredHeight() - oldHeight;
            break;
    }

    targetView.animate()
            .translationX(startTranslationX)
            .translationY(startTranslationY)
            .setInterpolator(new FastOutSlowInInterpolator())
            .setDuration(animationDuration)
            .start();
}
 
Example #7
Source File: Android8DefaultSceneAnimatorExecutor.java    From scene with Apache License 2.0 6 votes vote down vote up
@NonNull
@Override
protected Animator onPushAnimator(AnimationInfo from, final AnimationInfo to) {
    if (to.mIsTranslucent) {
        return mDialogSceneAnimatorExecutor.onPushAnimator(from, to);
    }
    final View fromView = from.mSceneView;
    final View toView = to.mSceneView;

    ValueAnimator fromAlphaAnimator = ObjectAnimator.ofFloat(fromView, View.ALPHA, 1.0f, 1.0f);//之前是0.7,但是动画后面会露出NavigationScene的背景色白色很怪异
    fromAlphaAnimator.setInterpolator(new FastOutSlowInInterpolator());
    fromAlphaAnimator.setDuration(120);

    ValueAnimator toAlphaAnimator = ObjectAnimator.ofFloat(toView, View.ALPHA, 0.0f, 1.0f);
    toAlphaAnimator.setInterpolator(new DecelerateInterpolator(2));
    toAlphaAnimator.setDuration(120);

    ValueAnimator toTranslateAnimator = ObjectAnimator.ofFloat(toView, View.TRANSLATION_Y, 0.08f * toView.getHeight(), 0);
    toTranslateAnimator.setInterpolator(new DecelerateInterpolator(2.5f));
    toTranslateAnimator.setDuration(200);
    return TransitionUtils.mergeAnimators(fromAlphaAnimator, toAlphaAnimator, toTranslateAnimator);
}
 
Example #8
Source File: Case1Scene.java    From scene with Apache License 2.0 6 votes vote down vote up
@NonNull
@Override
protected Animator onPushAnimator(AnimationInfo from, final AnimationInfo to) {
    final View fromView = from.mSceneView;
    final View toView = to.mSceneView;

    ValueAnimator fromAlphaAnimator = ObjectAnimator.ofFloat(fromView, View.ALPHA, 1.0f, 1.0f);//之前是0.7,但是动画后面会露出NavigationScene的背景色白色很怪异
    fromAlphaAnimator.setInterpolator(new FastOutSlowInInterpolator());
    fromAlphaAnimator.setDuration(120 * 20);

    ValueAnimator toAlphaAnimator = ObjectAnimator.ofFloat(toView, View.ALPHA, 0.0f, 1.0f);
    toAlphaAnimator.setInterpolator(new DecelerateInterpolator(2));
    toAlphaAnimator.setDuration(120 * 20);

    ValueAnimator toTranslateAnimator = ObjectAnimator.ofFloat(toView, View.TRANSLATION_Y, 0.08f * toView.getHeight(), 0);
    toTranslateAnimator.setInterpolator(new DecelerateInterpolator(2.5f));
    toTranslateAnimator.setDuration(200 * 20);
    return TransitionUtils.mergeAnimators(fromAlphaAnimator, toAlphaAnimator, toTranslateAnimator);
}
 
Example #9
Source File: Floaty.java    From Floaty with Apache License 2.0 6 votes vote down vote up
private void animateStageOut() {
    final ValueAnimator animator = new ValueAnimator();
    animator.setFloatValues(1F, 0F);
    animator.setInterpolator(new FastOutSlowInInterpolator());
    animator.setDuration(ANIMATION_DURATION);
    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            targetParent.removeView(stage);
        }
    });
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            float currentAlpha = (float) valueAnimator.getAnimatedValue();
            stage.setAlpha(currentAlpha);
        }
    });
    animator.start();
}
 
Example #10
Source File: AddressSelector.java    From JDAddressSelector with MIT License 6 votes vote down vote up
private AnimatorSet buildIndicatorAnimatorTowards(TextView tab) {
    ObjectAnimator xAnimator = ObjectAnimator.ofFloat(indicator, "X", indicator.getX(), tab.getX());

    final ViewGroup.LayoutParams params = indicator.getLayoutParams();
    ValueAnimator widthAnimator = ValueAnimator.ofInt(params.width, tab.getMeasuredWidth());
    widthAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            params.width = (int) animation.getAnimatedValue();
            indicator.setLayoutParams(params);
        }
    });

    AnimatorSet set = new AnimatorSet();
    set.setInterpolator(new FastOutSlowInInterpolator());
    set.playTogether(xAnimator, widthAnimator);

    return set;
}
 
Example #11
Source File: SegmentedButtonGroup.java    From SegmentedButton with Apache License 2.0 6 votes vote down vote up
private void initInterpolations() {
    ArrayList<Class> interpolatorList = new ArrayList<Class>() {{
        add(FastOutSlowInInterpolator.class);
        add(BounceInterpolator.class);
        add(LinearInterpolator.class);
        add(DecelerateInterpolator.class);
        add(CycleInterpolator.class);
        add(AnticipateInterpolator.class);
        add(AccelerateDecelerateInterpolator.class);
        add(AccelerateInterpolator.class);
        add(AnticipateOvershootInterpolator.class);
        add(FastOutLinearInInterpolator.class);
        add(LinearOutSlowInInterpolator.class);
        add(OvershootInterpolator.class);
    }};

    try {
        interpolatorSelector = (Interpolator) interpolatorList.get(animateSelector).newInstance();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #12
Source File: PostActivity.java    From materialup with Apache License 2.0 6 votes vote down vote up
private void handleVote(Upvote vote) {
    shot.setVoted(fab.isChecked());
    int count = vote.count;
    if (!fab.isChecked() && count > 0) {
        count -= 1;
    }

    if (count != shot.getVotes()) {
        shot.setVotes(count);
        updateVoteCount();
        AnimatorSet s = new AnimatorSet();
        s.setDuration(300).setInterpolator(new FastOutSlowInInterpolator());
        s.playTogether(
                ObjectAnimator.ofFloat(voteCount, "alpha", 0, 1, 1, 1),
                ObjectAnimator.ofFloat(voteCount, "scaleX", 0.3f, 1.05f, 0.9f, 1),
                ObjectAnimator.ofFloat(voteCount, "scaleY", 0.3f, 1.05f, 0.9f, 1));
        s.start();
    }
}
 
Example #13
Source File: BottomButton.java    From citrus with Apache License 2.0 6 votes vote down vote up
/**
 *
 * @param parent
 * @param bb
 * @param snackbar
 */
private void updateFabTranslationForSnackbar(CoordinatorLayout parent, BottomButton bb, View snackbar) {
    float translationY = this.getFabTranslationYForSnackbar(parent, bb);
    if (translationY != this.mTranslationY) {
        ViewCompat.animate(bb).cancel();
        if (Math.abs(translationY - this.mTranslationY) == (float) snackbar.getHeight()) {
            ViewCompat.animate(bb).translationY(translationY).setInterpolator(new FastOutSlowInInterpolator())
                    .setListener((ViewPropertyAnimatorListener) null);
        } else {
            ViewCompat.setTranslationY(bb, translationY);
        }

        this.mTranslationY = translationY;
    }

}
 
Example #14
Source File: SearchPanelController.java    From materialize with GNU General Public License v3.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private Animator makeSearchPanelAnimator(boolean reverse) {
    int width = container.getWidth();

    int centerX = container.getRight()
            + container.getPaddingRight()
            - resources.getDimensionPixelOffset(R.dimen.reveal_right) / 4 * 3;

    int centerY = container.getHeight() / 2;

    Animator animator = ViewAnimationUtils.createCircularReveal(container,
            centerX, centerY,
            reverse ? width : 0,
            reverse ? 0 : width);

    animator.setInterpolator(new FastOutSlowInInterpolator());

    animator.setDuration(resources.getInteger(android.R.integer.config_mediumAnimTime));

    return animator;
}
 
Example #15
Source File: MediaView.java    From Slide with GNU General Public License v3.0 6 votes vote down vote up
private static ValueAnimator slideAnimator(int start, int end, final View v) {
    ValueAnimator animator = ValueAnimator.ofInt(start, end);
    animator.setInterpolator(new FastOutSlowInInterpolator());

    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            //Update Height
            int value = (Integer) valueAnimator.getAnimatedValue();
            ViewGroup.LayoutParams layoutParams = v.getLayoutParams();
            layoutParams.height = value;
            v.setLayoutParams(layoutParams);
        }
    });
    return animator;
}
 
Example #16
Source File: CommentAdapterHelper.java    From Slide with GNU General Public License v3.0 6 votes vote down vote up
public static void showChildrenObject(final View v) {
    v.setVisibility(View.VISIBLE);
    ValueAnimator animator = ValueAnimator.ofFloat(0, 1f);
    animator.setDuration(250);
    animator.setInterpolator(new FastOutSlowInInterpolator());
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float value = ((Float) (animation.getAnimatedValue())).floatValue();
            v.setAlpha(value);
            v.setScaleX(value);
            v.setScaleY(value);
        }
    });

    animator.start();
}
 
Example #17
Source File: CommentAdapter.java    From Slide with GNU General Public License v3.0 6 votes vote down vote up
private ValueAnimator slideAnimator(int start, int end, final View v) {
    ValueAnimator animator = ValueAnimator.ofInt(start, end);
    animator.setInterpolator(new FastOutSlowInInterpolator());

    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            //Update Height
            int value = (Integer) valueAnimator.getAnimatedValue();
            ViewGroup.LayoutParams layoutParams = v.getLayoutParams();
            layoutParams.height = value;
            v.setLayoutParams(layoutParams);
        }
    });
    return animator;
}
 
Example #18
Source File: SubsamplingScaleImageView.java    From Slide with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Called by worker task when decoder is ready and image size and EXIF orientation is known.
 */
private synchronized void onTilesInited(ImageRegionDecoder decoder, int sWidth, int sHeight, int sOrientation) {
    // If actual dimensions don't match the declared size, reset everything.
    if (this.sWidth > 0 && this.sHeight > 0 && (this.sWidth != sWidth || this.sHeight != sHeight)) {
        reset(false);
        if (bitmap != null) {
            if (!bitmapIsCached) {
                bitmap.recycle();
            }
            bitmap = null;
            bitmapIsPreview = false;
            bitmapIsCached = false;
        }
    }
    this.decoder = decoder;
    this.sWidth = sWidth;
    this.sHeight = sHeight;
    this.sOrientation = sOrientation;
    checkReady();
    checkImageLoaded();
    invalidate();
    requestLayout();
    animate().setInterpolator(new FastOutSlowInInterpolator()).alpha(1);
}
 
Example #19
Source File: SubsamplingScaleImageView.java    From Slide with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Called by worker task when full size image bitmap is ready (tiling is disabled).
 */
private synchronized void onImageLoaded(Bitmap bitmap, int sOrientation, boolean bitmapIsCached) {
    // If actual dimensions don't match the declared size, reset everything.
    if (this.sWidth > 0 && this.sHeight > 0 && (this.sWidth != bitmap.getWidth() || this.sHeight != bitmap.getHeight())) {
        reset(false);
    }
    if (this.bitmap != null && !this.bitmapIsCached) {
        this.bitmap.recycle();
    }
    this.bitmapIsPreview = false;
    this.bitmapIsCached = bitmapIsCached;
    this.bitmap = bitmap;
    this.sWidth = bitmap.getWidth();
    this.sHeight = bitmap.getHeight();
    this.sOrientation = sOrientation;
    boolean ready = checkReady();
    boolean imageLoaded = checkImageLoaded();
    if (ready || imageLoaded) {
        invalidate();
        requestLayout();
    }
    animate().setInterpolator(new FastOutSlowInInterpolator()).alpha(1);
}
 
Example #20
Source File: CreateCardView.java    From Slide with GNU General Public License v3.0 6 votes vote down vote up
private static ValueAnimator slideAnimator(int start, int end, final View v) {
    ValueAnimator animator = ValueAnimator.ofInt(start, end);
    animator.setInterpolator(new FastOutSlowInInterpolator());

    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            //Update Height
            int value = (Integer) valueAnimator.getAnimatedValue();
            ViewGroup.LayoutParams layoutParams = v.getLayoutParams();
            layoutParams.height = value;
            v.setLayoutParams(layoutParams);
        }
    });
    return animator;
}
 
Example #21
Source File: CreateCardView.java    From Slide with GNU General Public License v3.0 6 votes vote down vote up
private static ValueAnimator flipAnimator(boolean isFlipped, final View v) {
    if (v != null) {
        ValueAnimator animator = ValueAnimator.ofFloat(isFlipped ? -1f : 1f, isFlipped ? 1f : -1f);
        animator.setInterpolator(new FastOutSlowInInterpolator());

        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                //Update Height
                v.setScaleY((Float) valueAnimator.getAnimatedValue());
            }
        });
        return animator;
    }
    return null;
}
 
Example #22
Source File: RadioRealButtonGroup.java    From RadioRealButton with Apache License 2.0 5 votes vote down vote up
private void initInterpolations() {
    Class[] interpolations = {
            FastOutSlowInInterpolator.class,
            BounceInterpolator.class,
            LinearInterpolator.class,
            DecelerateInterpolator.class,
            CycleInterpolator.class,
            AnticipateInterpolator.class,
            AccelerateDecelerateInterpolator.class,
            AccelerateInterpolator.class,
            AnticipateOvershootInterpolator.class,
            FastOutLinearInInterpolator.class,
            LinearOutSlowInInterpolator.class,
            OvershootInterpolator.class};

    try {
        interpolatorText = (Interpolator) interpolations[animateTextsEnter].newInstance();
        interpolatorDrawablesEnter = (Interpolator) interpolations[animateDrawablesEnter].newInstance();
        interpolatorSelector = (Interpolator) interpolations[animateSelector].newInstance();

        interpolatorTextExit = (Interpolator) interpolations[animateTextsExit].newInstance();
        interpolatorDrawablesExit = (Interpolator) interpolations[animateDrawablesExit].newInstance();

    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #23
Source File: TranslateAnimator.java    From YCDialog with Apache License 2.0 5 votes vote down vote up
@Override
public void animateShow() {
    targetView.animate()
            .translationX(initTranslationX)
            .translationY(initTranslationY)
            .setInterpolator(new FastOutSlowInInterpolator())
            .setDuration(animationDuration)
            .start();
}
 
Example #24
Source File: SplashActivity.java    From Saude-no-Mapa with MIT License 5 votes vote down vote up
@Override
public void animateLogoImage(Runnable endRunnable) {
    logoImage.animate()
            .alpha(1)
            .setDuration(2000)
            .setInterpolator(new FastOutSlowInInterpolator())
            .withEndAction(endRunnable);

    concursoLogo.animate()
            .alpha(1)
            .setDuration(2000)
            .setInterpolator(new FastOutSlowInInterpolator());

    tcuLogoImage.animate()
            .alpha(1)
            .setDuration(2000)
            .setInterpolator(new FastOutSlowInInterpolator());

    tcuLogoImage.animate()
            .scaleX(1)
            .setDuration(2000)
            .setInterpolator(new FastOutSlowInInterpolator());

    loginBackgroundImage.animate()
            .scaleXBy(0.5f)
            .scaleYBy(0.5f)
            .setInterpolator(new FastOutSlowInInterpolator())
            .setDuration(2000);
}
 
Example #25
Source File: InkPageIndicator.java    From material-intro-screen with MIT License 5 votes vote down vote up
public InkPageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final int density = (int) context.getResources().getDisplayMetrics().density;

    final TypedArray typedArray = getContext().obtainStyledAttributes(
            attrs, R.styleable.InkPageIndicator, defStyle, 0);

    dotDiameter = typedArray.getDimensionPixelSize(R.styleable.InkPageIndicator_dotDiameter, DEFAULT_DOT_SIZE * density);
    dotRadius = dotDiameter / 2;
    halfDotRadius = dotRadius / 2;
    gap = typedArray.getDimensionPixelSize(R.styleable.InkPageIndicator_dotGap, DEFAULT_GAP * density);
    animDuration = (long) typedArray.getInteger(R.styleable.InkPageIndicator_animationDuration, DEFAULT_ANIM_DURATION);
    animHalfDuration = animDuration / 2;
    unselectedColour = typedArray.getColor(R.styleable.InkPageIndicator_pageIndicatorColor, DEFAULT_UNSELECTED_COLOUR);
    int selectedColour = typedArray.getColor(R.styleable.InkPageIndicator_currentPageIndicatorColor, DEFAULT_SELECTED_COLOUR);
    typedArray.recycle();

    unselectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    unselectedPaint.setColor(unselectedColour);
    selectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    selectedPaint.setColor(selectedColour);
    interpolator = new FastOutSlowInInterpolator();

    combinedUnselectedPath = new Path();
    unselectedDotPath = new Path();
    unselectedDotLeftPath = new Path();
    unselectedDotRightPath = new Path();
    rectF = new RectF();

    addOnAttachStateChangeListener(this);
}
 
Example #26
Source File: Utils.java    From ExpandableLayout with Apache License 2.0 5 votes vote down vote up
/**
 * Creates interpolator.
 *
 * @param interpolatorType
 * @return
 */
public static TimeInterpolator createInterpolator(@IntRange(from = 0, to = 10) final int interpolatorType) {
    switch (interpolatorType) {
        case ACCELERATE_DECELERATE_INTERPOLATOR:
            return new AccelerateDecelerateInterpolator();
        case ACCELERATE_INTERPOLATOR:
            return new AccelerateInterpolator();
        case ANTICIPATE_INTERPOLATOR:
            return new AnticipateInterpolator();
        case ANTICIPATE_OVERSHOOT_INTERPOLATOR:
            return new AnticipateOvershootInterpolator();
        case BOUNCE_INTERPOLATOR:
            return new BounceInterpolator();
        case DECELERATE_INTERPOLATOR:
            return new DecelerateInterpolator();
        case FAST_OUT_LINEAR_IN_INTERPOLATOR:
            return new FastOutLinearInInterpolator();
        case FAST_OUT_SLOW_IN_INTERPOLATOR:
            return new FastOutSlowInInterpolator();
        case LINEAR_INTERPOLATOR:
            return new LinearInterpolator();
        case LINEAR_OUT_SLOW_IN_INTERPOLATOR:
            return new LinearOutSlowInInterpolator();
        case OVERSHOOT_INTERPOLATOR:
            return new OvershootInterpolator();
        default:
            return new LinearInterpolator();
    }
}
 
Example #27
Source File: SubsamplingScaleImageView.java    From Slide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Called by worker task when a tile has loaded. Redraws the view.
 */
private synchronized void onTileLoaded() {
    checkReady();
    checkImageLoaded();
    if (isBaseLayerReady() && bitmap != null) {
        if (!bitmapIsCached) {
            bitmap.recycle();
        }
        bitmap = null;
        bitmapIsPreview = false;
        bitmapIsCached = false;
    }
    invalidate();
    animate().setInterpolator(new FastOutSlowInInterpolator()).alpha(1);
}
 
Example #28
Source File: InkPageIndicator.java    From InkPageIndicator with Apache License 2.0 5 votes vote down vote up
public InkPageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final int density = (int) context.getResources().getDisplayMetrics().density;

    // Load attributes
    final TypedArray a = getContext().obtainStyledAttributes(
            attrs, R.styleable.InkPageIndicator, defStyle, 0);

    dotDiameter = a.getDimensionPixelSize(R.styleable.InkPageIndicator_dotDiameter,
            DEFAULT_DOT_SIZE * density);
    dotRadius = dotDiameter / 2;
    halfDotRadius = dotRadius / 2;
    gap = a.getDimensionPixelSize(R.styleable.InkPageIndicator_dotGap,
            DEFAULT_GAP * density);
    animDuration = (long) a.getInteger(R.styleable.InkPageIndicator_animationDuration,
            DEFAULT_ANIM_DURATION);
    animHalfDuration = animDuration / 2;
    unselectedColour = a.getColor(R.styleable.InkPageIndicator_pageIndicatorColor,
            DEFAULT_UNSELECTED_COLOUR);
    selectedColour = a.getColor(R.styleable.InkPageIndicator_currentPageIndicatorColor,
            DEFAULT_SELECTED_COLOUR);

    a.recycle();

    unselectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    unselectedPaint.setColor(unselectedColour);
    selectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    selectedPaint.setColor(selectedColour);
    interpolator = new FastOutSlowInInterpolator();

    // create paths & rect now – reuse & rewind later
    combinedUnselectedPath = new Path();
    unselectedDotPath = new Path();
    unselectedDotLeftPath = new Path();
    unselectedDotRightPath = new Path();
    rectF = new RectF();

    addOnAttachStateChangeListener(this);
}
 
Example #29
Source File: InkPageIndicator.java    From youqu_master with Apache License 2.0 5 votes vote down vote up
public InkPageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final int density = (int) context.getResources().getDisplayMetrics().density;

    final TypedArray typedArray = getContext().obtainStyledAttributes(
            attrs, R.styleable.InkPageIndicator, defStyle, 0);

    dotDiameter = typedArray.getDimensionPixelSize(R.styleable.InkPageIndicator_dotDiameter, DEFAULT_DOT_SIZE * density);
    dotRadius = dotDiameter / 2;
    halfDotRadius = dotRadius / 2;
    gap = typedArray.getDimensionPixelSize(R.styleable.InkPageIndicator_dotGap, DEFAULT_GAP * density);
    animDuration = (long) typedArray.getInteger(R.styleable.InkPageIndicator_animationDuration, DEFAULT_ANIM_DURATION);
    animHalfDuration = animDuration / 2;
    unselectedColour = typedArray.getColor(R.styleable.InkPageIndicator_pageIndicatorColor, DEFAULT_UNSELECTED_COLOUR);
    int selectedColour = typedArray.getColor(R.styleable.InkPageIndicator_currentPageIndicatorColor, DEFAULT_SELECTED_COLOUR);
    typedArray.recycle();

    unselectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    unselectedPaint.setColor(unselectedColour);
    selectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    selectedPaint.setColor(selectedColour);
    interpolator = new FastOutSlowInInterpolator();

    combinedUnselectedPath = new Path();
    unselectedDotPath = new Path();
    unselectedDotLeftPath = new Path();
    unselectedDotRightPath = new Path();
    rectF = new RectF();

    addOnAttachStateChangeListener(this);
}
 
Example #30
Source File: FABSnackbarBehavior.java    From FABsMenu with Apache License 2.0 5 votes vote down vote up
/**
 * Animate FAB on snackbar change.
 */
private void updateFabTranslationForSnackbar(CoordinatorLayout parent, View fab,
                                             View snackbar) {
    final float translationY = getFabTranslationYForSnackbar(parent, fab);
    if (translationY != this.mTranslationY) {
        ViewCompat.animate(fab).cancel();
        if (Math.abs(translationY - this.mTranslationY) == (float) snackbar.getHeight()) {
            ViewCompat.animate(fab).translationY(translationY).setInterpolator(
                    new FastOutSlowInInterpolator());
        } else {
            fab.setTranslationY(translationY);
        }
        this.mTranslationY = translationY;
    }
}