android.view.animation.AnticipateInterpolator Java Examples

The following examples show how to use android.view.animation.AnticipateInterpolator. 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: MainActivity.java    From CircularProgressDrawable with Apache License 2.0 6 votes vote down vote up
/**
 * Style 3 animation will turn a 3/4 animation with Anticipate/Overshoot interpolation to a
 * blank waiting - like state, wait for 2 seconds then return to the original state
 *
 * @return Animation
 */
private Animator prepareStyle3Animation() {
    AnimatorSet animation = new AnimatorSet();

    ObjectAnimator progressAnimation = ObjectAnimator.ofFloat(drawable, CircularProgressDrawable.PROGRESS_PROPERTY, 0.75f, 0f);
    progressAnimation.setDuration(1200);
    progressAnimation.setInterpolator(new AnticipateInterpolator());

    Animator innerCircleAnimation = ObjectAnimator.ofFloat(drawable, CircularProgressDrawable.CIRCLE_SCALE_PROPERTY, 0.75f, 0f);
    innerCircleAnimation.setDuration(1200);
    innerCircleAnimation.setInterpolator(new AnticipateInterpolator());

    ObjectAnimator invertedProgress = ObjectAnimator.ofFloat(drawable, CircularProgressDrawable.PROGRESS_PROPERTY, 0f, 0.75f);
    invertedProgress.setDuration(1200);
    invertedProgress.setStartDelay(3200);
    invertedProgress.setInterpolator(new OvershootInterpolator());

    Animator invertedCircle = ObjectAnimator.ofFloat(drawable, CircularProgressDrawable.CIRCLE_SCALE_PROPERTY, 0f, 0.75f);
    invertedCircle.setDuration(1200);
    invertedCircle.setStartDelay(3200);
    invertedCircle.setInterpolator(new OvershootInterpolator());

    animation.playTogether(progressAnimation, innerCircleAnimation, invertedProgress, invertedCircle);
    return animation;
}
 
Example #2
Source File: ShareCard.java    From timecat with Apache License 2.0 6 votes vote down vote up
public void hide() {
    post(new Runnable() {
        @Override
        public void run() {
            ObjectAnimator objectAnimator = ObjectAnimator.ofInt(ShareCard.this, "height", 0);
            objectAnimator.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    setVisibility(GONE);
                    if (mListener != null) {
                        mListener.onClick(ShareCard.this);
                    }
                }
            });
            objectAnimator.setDuration(500);
            objectAnimator.setInterpolator(new AnticipateInterpolator());
            objectAnimator.setRepeatCount(0);
            objectAnimator.start();
        }
    });
}
 
Example #3
Source File: IntroCard.java    From timecat with Apache License 2.0 6 votes vote down vote up
public void hide() {
    post(new Runnable() {
        @Override
        public void run() {
            ObjectAnimator objectAnimator = ObjectAnimator.ofInt(IntroCard.this, "height", 0);
            objectAnimator.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    setVisibility(GONE);
                    if (mListener != null) {
                        mListener.onClick(IntroCard.this);
                    }
                }
            });
            objectAnimator.setDuration(500);
            objectAnimator.setInterpolator(new AnticipateInterpolator());
            objectAnimator.setRepeatCount(0);
            objectAnimator.start();
        }
    });
}
 
Example #4
Source File: InterpolatorSelector.java    From ParallaxEverywhere with MIT License 6 votes vote down vote up
public static Interpolator interpolatorId(int interpolationId) {
    switch (interpolationId) {
        case LINEAR:
        default:
            return new LinearInterpolator();
        case ACCELERATE_DECELERATE:
            return new AccelerateDecelerateInterpolator();
        case ACCELERATE:
            return new AccelerateInterpolator();
        case ANTICIPATE:
            return new AnticipateInterpolator();
        case ANTICIPATE_OVERSHOOT:
            return new AnticipateOvershootInterpolator();
        case BOUNCE:
            return new BounceInterpolator();
        case DECELERATE:
            return new DecelerateInterpolator();
        case OVERSHOOT:
            return new OvershootInterpolator();
        //TODO: this interpolations needs parameters
        //case CYCLE:
        //    return new CycleInterpolator();
        //case PATH:
        //    return new PathInterpolator();
    }
}
 
Example #5
Source File: DrawerGradientActivity.java    From android-transition with Apache License 2.0 6 votes vote down vote up
public void updateTransition(View v) {
    mDrawerListenerAdapter.removeAllTransitions();

    ViewTransitionBuilder builder = ViewTransitionBuilder.transit(mGradient).translationX(-mGradient.getWidth(), 0);
    switch (v.getId()) {
        case R.id.interpolator_default:
            break;
        case R.id.interpolator_linear:
            builder.interpolator(new LinearInterpolator());
            break;
        case R.id.interpolator_accelerate:
            builder.interpolator(new AccelerateInterpolator());
            break;
        case R.id.interpolator_decelerate:
            builder.interpolator(new DecelerateInterpolator());
            break;
        case R.id.interpolator_fastout:
            builder.interpolator(new FastOutLinearInInterpolator());
            break;
        case R.id.interpolator_anticipate:
            builder.interpolator(new AnticipateInterpolator());
            break;
    }
    mDrawerListenerAdapter.addTransition(builder);
}
 
Example #6
Source File: DemoLikePathActivity.java    From ArcLayout with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("NewApi")
private void hideMenu() {

  List<Animator> animList = new ArrayList<>();

  for (int i = arcLayout.getChildCount() - 1; i >= 0; i--) {
    animList.add(createHideItemAnimator(arcLayout.getChildAt(i)));
  }

  AnimatorSet animSet = new AnimatorSet();
  animSet.setDuration(400);
  animSet.setInterpolator(new AnticipateInterpolator());
  animSet.playTogether(animList);
  animSet.addListener(new AnimatorListenerAdapter() {
    @Override
    public void onAnimationEnd(Animator animation) {
      super.onAnimationEnd(animation);
      menuLayout.setVisibility(View.INVISIBLE);
    }
  });
  animSet.start();

}
 
Example #7
Source File: TranslationHideAnimator.java    From AndroidSkinAnimator with MIT License 6 votes vote down vote up
@Override
public SkinAnimator apply(@NonNull final View view, @Nullable final Action action) {
    animator = ObjectAnimator.ofPropertyValuesHolder(view,
            PropertyValuesHolder.ofFloat("alpha", 1, 0),
            PropertyValuesHolder.ofFloat("translationX", view.getLeft(), view.getRight()));
    animator.setDuration(3 * PRE_DURATION);
    animator.setInterpolator(new AnticipateInterpolator());
    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            resetView(view);
            if (action != null) {
                action.action();
            }
        }
    });
    return this;
}
 
Example #8
Source File: ScaleHideAnimator.java    From AndroidSkinAnimator with MIT License 6 votes vote down vote up
@Override
public SkinAnimator apply(@NonNull final View view, @Nullable final Action action) {
    animator = ObjectAnimator.ofPropertyValuesHolder(view,
            PropertyValuesHolder.ofFloat("alpha", 1, 0),
            PropertyValuesHolder.ofFloat("scaleX", 1, 0),
            PropertyValuesHolder.ofFloat("scaleY", 1, 0)
    );
    animator.setDuration(3 * PRE_DURATION);
    animator.setInterpolator(new AnticipateInterpolator());
    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            resetView(view);
            if (action != null) {
                action.action();
            }
        }
    });
    return this;
}
 
Example #9
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 #10
Source File: MainActivity.java    From journaldev with MIT License 5 votes vote down vote up
private void showAnimation() {
    show = true;

    ConstraintSet constraintSet = new ConstraintSet();
    constraintSet.clone(this, R.layout.activity_main_animation);

    ChangeBounds transition = new ChangeBounds();
    transition.setInterpolator(new AnticipateInterpolator(1.0f));
    transition.setDuration(1200);

    TransitionManager.beginDelayedTransition(cc1, transition);
    constraintSet.applyTo(cc1);
}
 
Example #11
Source File: MainActivity.java    From journaldev with MIT License 5 votes vote down vote up
private void revertAnimation() {
    show = false;

    ConstraintSet constraintSet = new ConstraintSet();
    constraintSet.clone(this, R.layout.activity_main);

    ChangeBounds transition = new ChangeBounds();
    transition.setInterpolator(new AnticipateInterpolator(1.0f));
    transition.setDuration(1200);

    TransitionManager.beginDelayedTransition(cc1, transition);
    constraintSet.applyTo(cc1);

}
 
Example #12
Source File: GeneralAnimatorGenerator.java    From IndicatorBox with MIT License 5 votes vote down vote up
/**
 * Make a shrink animation.
 * @param duration
 * @return
 */
public static Animator shrinkAnimator(int duration){
    AnimatorSet animatorSet = new AnimatorSet();
    ObjectAnimator xExpandAnimator = new ObjectAnimator();
    xExpandAnimator.setPropertyName("scaleX");
    xExpandAnimator.setFloatValues(1.0f, 0.5f);
    ObjectAnimator yExpandAnimator = new ObjectAnimator();
    yExpandAnimator.setPropertyName("scaleY");
    yExpandAnimator.setFloatValues(1.0f, 0.5f);
    animatorSet.play(xExpandAnimator).with(yExpandAnimator);
    animatorSet.setDuration(duration);
    animatorSet.setInterpolator(new AnticipateInterpolator());
    return animatorSet;
}
 
Example #13
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 #14
Source File: AnimationController.java    From FamilyChat with Apache License 2.0 5 votes vote down vote up
private void setEffect(Animation animation, int interpolatorType, long durationMillis, long delayMillis)
{
	switch (interpolatorType)
	{
	case 0:
		animation.setInterpolator(new LinearInterpolator());
		break;
	case 1:
		animation.setInterpolator(new AccelerateInterpolator());
		break;
	case 2:
		animation.setInterpolator(new DecelerateInterpolator());
		break;
	case 3:
		animation.setInterpolator(new AccelerateDecelerateInterpolator());
		break;
	case 4:
		animation.setInterpolator(new BounceInterpolator());
		break;
	case 5:
		animation.setInterpolator(new OvershootInterpolator());
		break;
	case 6:
		animation.setInterpolator(new AnticipateInterpolator());
		break;
	case 7:
		animation.setInterpolator(new AnticipateOvershootInterpolator());
		break;
	default:
		break;
	}
	animation.setDuration(durationMillis);
	animation.setStartOffset(delayMillis);
}
 
Example #15
Source File: AnimationController.java    From lunzi with Apache License 2.0 5 votes vote down vote up
private static void setEffect(Animation animation, int interpolatorType, long durationMillis, long delayMillis) {
    switch (interpolatorType) {
        case 0:
            animation.setInterpolator(new LinearInterpolator());
            break;
        case 1:
            animation.setInterpolator(new AccelerateInterpolator());
            break;
        case 2:
            animation.setInterpolator(new DecelerateInterpolator());
            break;
        case 3:
            animation.setInterpolator(new AccelerateDecelerateInterpolator());
            break;
        case 4:
            animation.setInterpolator(new BounceInterpolator());
            break;
        case 5:
            animation.setInterpolator(new OvershootInterpolator());
            break;
        case 6:
            animation.setInterpolator(new AnticipateInterpolator());
            break;
        case 7:
            animation.setInterpolator(new AnticipateOvershootInterpolator());
            break;
        default:
            break;
    }
    animation.setDuration(durationMillis);
    animation.setStartOffset(delayMillis);
}
 
Example #16
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 #17
Source File: SampleInterpolatorsFragment.java    From android-DecoView-charting with Apache License 2.0 5 votes vote down vote up
@Override
protected void createTracks() {
    if (getView() != null) {
        createTracks(R.id.dynamicArcView1, new LinearInterpolator(), Color.parseColor("#CC0000"));
        createTracks(R.id.dynamicArcView2, new AnticipateInterpolator(), Color.parseColor("#048482"));
        createTracks(R.id.dynamicArcView3, new AccelerateInterpolator(), Color.parseColor("#003366"));
        createTracks(R.id.dynamicArcView4, new DecelerateInterpolator(), Color.parseColor("#66A7C5"));
        createTracks(R.id.dynamicArcView5, new BounceInterpolator(), Color.parseColor("#FF6000"));
        createTracks(R.id.dynamicArcView6, new OvershootInterpolator(), Color.parseColor("#6F0564"));
    }
}
 
Example #18
Source File: ExpandableButtonMenu.java    From ExpandableButtonMenu with Apache License 2.0 5 votes vote down vote up
/**
 * Initialized animation properties
 */
private void calculateAnimationProportions() {
    TRANSLATION_Y = sHeight * buttonDistanceY;
    TRANSLATION_X = sWidth * buttonDistanceX;

    anticipation = new AnticipateInterpolator(INTERPOLATOR_WEIGHT);
    overshoot = new OvershootInterpolator(INTERPOLATOR_WEIGHT);
}
 
Example #19
Source File: RotateAnimater.java    From JPTabBar with Apache License 2.0 5 votes vote down vote up
@Override
public void onSelectChanged(View v, boolean selected) {
    int end = selected ? 360 : 0;
    ObjectAnimator rotateAnimator = ObjectAnimator.ofFloat(v, "rotation",  end);
    rotateAnimator.setDuration(400);
    rotateAnimator.setInterpolator(new AnticipateInterpolator());
    rotateAnimator.start();
}
 
Example #20
Source File: BezierPraiseAnimator.java    From kAndroid with Apache License 2.0 5 votes vote down vote up
private ValueAnimator getBezierPraiseAnimator(final View target) {
    // 构建贝塞尔曲线的起点,控制点,终点坐标
    float startX = mTargetX;
    float startY = mTargetY;
    int random = mRandom.nextInt(mPraiseIconWidth);
    float endX;
    float endY;
    float controlX;
    final float controlY;

    controlY = startY - mRandom.nextInt(500) - 100;
    // 左右两边
    if (random % 2 == 0) {
        endX = mTargetX - random * 8;
        controlX = mTargetX - random * 2;
    } else {
        endX = mTargetX + random * 8;
        controlX = mTargetX + random * 2;
    }
    endY = mTargetY + random + 400;

    // 构造自定义的贝塞尔估值器
    PraiseEvaluator evaluator = new PraiseEvaluator(new PointF(controlX, controlY));

    ValueAnimator animator = ValueAnimator.ofObject(evaluator, new PointF(startX, startY), new PointF(endX, endY));
    animator.setInterpolator(new AnticipateInterpolator());
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            PointF currentPoint = (PointF) animation.getAnimatedValue();
            target.setX(currentPoint.x);
            target.setY(currentPoint.y);
            // 设置透明度 [1~0]
            target.setAlpha(1.0f - animation.getAnimatedFraction());
        }
    });
    animator.setTarget(target);
    return animator;
}
 
Example #21
Source File: UDInterpolator.java    From VideoOS-Android-SDK with GNU General Public License v3.0 5 votes vote down vote up
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();
            default:
                return new LinearInterpolator();
        }
    } else {
        return new LinearInterpolator();
    }
}
 
Example #22
Source File: Animation.java    From MusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
public static List<Interpolator> getInterpolatorList() {
    List<Interpolator> interpolatorList = new ArrayList<>();
    interpolatorList.add(new LinearInterpolator());
    interpolatorList.add(new AccelerateInterpolator());
    interpolatorList.add(new DecelerateInterpolator());
    interpolatorList.add(new AccelerateDecelerateInterpolator());
    interpolatorList.add(new OvershootInterpolator());
    interpolatorList.add(new AnticipateInterpolator());
    interpolatorList.add(new AnticipateOvershootInterpolator());
    interpolatorList.add(new BounceInterpolator());
    interpolatorList.add(new FastOutLinearInInterpolator());
    interpolatorList.add(new FastOutSlowInInterpolator());
    interpolatorList.add(new LinearOutSlowInInterpolator());
    return interpolatorList;
}
 
Example #23
Source File: Animation.java    From MusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
@NonNull
public static Interpolator getInterpolator(int id) {
    switch (id) {
        case 0:
            return new LinearInterpolator();
        case 1:
            return new AccelerateInterpolator();
        case 2:
            return new DecelerateInterpolator();
        case 3:
            return new AccelerateDecelerateInterpolator();
        case 4:
            return new OvershootInterpolator();
        case 5:
            return new AnticipateInterpolator();
        case 6:
            return new AnticipateOvershootInterpolator();
        case 7:
            return new BounceInterpolator();
        case 8:
            return new FastOutLinearInInterpolator();
        case 9:
            return new LinearInterpolator();
        case 10:
            return new LinearOutSlowInInterpolator();
        default:
            return new FastOutSlowInInterpolator();
    }
}
 
Example #24
Source File: TranslationAnimator.java    From AndroidSkinAnimator with MIT License 5 votes vote down vote up
@Override
public SkinAnimator apply(@NonNull View view, @Nullable final Action action) {
    this.targetView = view;
    preAnimator = ObjectAnimator.ofPropertyValuesHolder(targetView,
            PropertyValuesHolder.ofFloat("alpha", 1, 0),
            PropertyValuesHolder.ofFloat("translationX",
                    view.getLeft(), view.getRight()))
            .setDuration(PRE_DURATION * 3);
    preAnimator.setInterpolator(new AnticipateInterpolator());
    afterAnimator = ObjectAnimator.ofPropertyValuesHolder(targetView,
            PropertyValuesHolder.ofFloat("translationX",
                    view.getRight(), view.getLeft()))
            .setDuration(AFTER_DURATION * 2);
    afterAnimator.setInterpolator(new BounceInterpolator());

    preAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            targetView.setAlpha(1);
            if (action != null) {
                action.action();
            }
            afterAnimator.start();
        }
    });
    return this;
}
 
Example #25
Source File: NeuralModelActivity.java    From Synapse with Apache License 2.0 5 votes vote down vote up
public void onConfirm(View view) {
    final Model model = checkInputs();

    if (model == null) {
        return;
    }

    final Intent intent = new Intent(this, MainService.class);
    intent.putExtra(MainService.ACTION_KEY, MainService.ACTION_TRAIN);
    intent.putExtra(MainService.EXTRAS_NEURAL_CONFIG, model);
    startService(intent);

    final int height = mContainer.getHeight();
    final Activity that = this;

    mPage.setClickable(false);

    mContainer.animate()
            .y(-height)
            .alpha(0F)
            .setInterpolator(new AnticipateInterpolator())
            .setDuration(300)
            .withEndAction(new Runnable() {
                @Override
                public void run() {
                    if (!that.isFinishing()) {
                        that.finish();
                    }
                }
            }).start();

    Tracker.getInstance()
            .event(TrackCons.Model.CLICK_TRAIN)
            .put(TrackCons.Key.MSG, snapshot(model))
            .log();
}
 
Example #26
Source File: ObjectAnimationActivity.java    From MaterialDesignDemo with MIT License 5 votes vote down vote up
private void startAnimation() {
        ObjectAnimator oa = ObjectAnimator.ofFloat(mIvPic, "translationY", 0, 400);
        // 加速减速插值器
//        AccelerateDecelerateInterpolator interpolator = new AccelerateDecelerateInterpolator();
        // 加速插值器
//        AccelerateInterpolator interpolator = new AccelerateInterpolator(0.8f);
        // 回荡秋千插值器
        AnticipateInterpolator interpolator = new AnticipateInterpolator(0.8f);
        oa.setInterpolator(interpolator);
        oa.start();
    }
 
Example #27
Source File: PathProgressDrawable.java    From samples with MIT License 5 votes vote down vote up
public void setAnimatedPoints(int animatedPoints) {
        float dist = 1f / (float) (animatedPoints - 2);
//        Interpolator interpolator = new AccelerateInterpolator();
//        Interpolator interpolator = new DecelerateInterpolator();
        Interpolator interpolator = new AnticipateInterpolator();

        mFactor = new float[animatedPoints];
        for (int i = 0; i < animatedPoints - 1; i++) {
            mFactor[i] = 1f + interpolator.getInterpolation(dist * i);
        }
        mFactor[animatedPoints - 1] = 1f;
    }
 
Example #28
Source File: JumpAnimater.java    From JPTabBar with Apache License 2.0 5 votes vote down vote up
@Override
public void onSelectChanged(View v, boolean selected) {
    int end = selected?-10:0;
    ObjectAnimator jumpAnimator = ObjectAnimator.ofFloat(v,"translationY",end);
    jumpAnimator.setDuration(300);
    jumpAnimator.setInterpolator(new AnticipateInterpolator());
    jumpAnimator.start();
}
 
Example #29
Source File: FloatingActionMenu.java    From ShareBox with Apache License 2.0 4 votes vote down vote up
private void init(Context context, AttributeSet attrs) {
    TypedArray attr = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionMenu, 0, 0);
    mButtonSpacing = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_buttonSpacing, mButtonSpacing);
    mLabelsMargin = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_margin, mLabelsMargin);
    mLabelsPosition = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_position, LABELS_POSITION_LEFT);
    mLabelsShowAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_showAnimation,
            mLabelsPosition == LABELS_POSITION_LEFT ? R.anim.fab_slide_in_from_right : R.anim.fab_slide_in_from_left);
    mLabelsHideAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_hideAnimation,
            mLabelsPosition == LABELS_POSITION_LEFT ? R.anim.fab_slide_out_to_right : R.anim.fab_slide_out_to_left);
    mLabelsPaddingTop = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingTop, mLabelsPaddingTop);
    mLabelsPaddingRight = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingRight, mLabelsPaddingRight);
    mLabelsPaddingBottom = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingBottom, mLabelsPaddingBottom);
    mLabelsPaddingLeft = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingLeft, mLabelsPaddingLeft);
    mLabelsTextColor = attr.getColorStateList(R.styleable.FloatingActionMenu_menu_labels_textColor);
    // set default value if null same as for textview
    if (mLabelsTextColor == null) {
        mLabelsTextColor = ColorStateList.valueOf(Color.WHITE);
    }
    mLabelsTextSize = attr.getDimension(R.styleable.FloatingActionMenu_menu_labels_textSize, getResources().getDimension(R.dimen.labels_text_size));
    mLabelsCornerRadius = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_cornerRadius, mLabelsCornerRadius);
    mLabelsShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_showShadow, true);
    mLabelsColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorNormal, 0xFF333333);
    mLabelsColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorPressed, 0xFF444444);
    mLabelsColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorRipple, 0x66FFFFFF);
    mMenuShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_showShadow, true);
    mMenuShadowColor = attr.getColor(R.styleable.FloatingActionMenu_menu_shadowColor, 0x66000000);
    mMenuShadowRadius = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowRadius, mMenuShadowRadius);
    mMenuShadowXOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowXOffset, mMenuShadowXOffset);
    mMenuShadowYOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowYOffset, mMenuShadowYOffset);
    mMenuColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_colorNormal, 0xFFDA4336);
    mMenuColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_colorPressed, 0xFFE75043);
    mMenuColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_colorRipple, 0x99FFFFFF);
    mAnimationDelayPerItem = attr.getInt(R.styleable.FloatingActionMenu_menu_animationDelayPerItem, 50);
    mIcon = attr.getDrawable(R.styleable.FloatingActionMenu_menu_icon);
    if (mIcon == null) {
        mIcon = getResources().getDrawable(R.drawable.fab_add);
    }
    mLabelsSingleLine = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_singleLine, false);
    mLabelsEllipsize = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_ellipsize, 0);
    mLabelsMaxLines = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_maxLines, -1);
    mMenuFabSize = attr.getInt(R.styleable.FloatingActionMenu_menu_fab_size, FloatingActionButton.SIZE_NORMAL);
    mLabelsStyle = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_style, 0);
    String customFont = attr.getString(R.styleable.FloatingActionMenu_menu_labels_customFont);
    try {
        if (!TextUtils.isEmpty(customFont)) {
            mCustomTypefaceFromFont = Typeface.createFromAsset(getContext().getAssets(), customFont);
        }
    } catch (RuntimeException ex) {
        throw new IllegalArgumentException("Unable to load specified custom font: " + customFont, ex);
    }
    mOpenDirection = attr.getInt(R.styleable.FloatingActionMenu_menu_openDirection, OPEN_UP);
    mBackgroundColor = attr.getColor(R.styleable.FloatingActionMenu_menu_backgroundColor, Color.TRANSPARENT);

    if (attr.hasValue(R.styleable.FloatingActionMenu_menu_fab_label)) {
        mUsingMenuLabel = true;
        mMenuLabelText = attr.getString(R.styleable.FloatingActionMenu_menu_fab_label);
    }

    if (attr.hasValue(R.styleable.FloatingActionMenu_menu_labels_padding)) {
        int padding = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_padding, 0);
        initPadding(padding);
    }

    mOpenInterpolator = new OvershootInterpolator();
    mCloseInterpolator = new AnticipateInterpolator();
    mLabelsContext = new ContextThemeWrapper(getContext(), mLabelsStyle);

    initBackgroundDimAnimation();
    createMenuButton();
    initMenuButtonAnimations(attr);

    attr.recycle();
}
 
Example #30
Source File: FloatingActionMenu.java    From clear-todolist with GNU General Public License v3.0 4 votes vote down vote up
private void init(Context context, AttributeSet attrs) {
    TypedArray attr = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionMenu, 0, 0);
    mButtonSpacing = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_buttonSpacing, mButtonSpacing);
    mLabelsMargin = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_margin, mLabelsMargin);
    mLabelsPosition = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_position, LABELS_POSITION_LEFT);
    mLabelsShowAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_showAnimation,
            mLabelsPosition == LABELS_POSITION_LEFT ? R.anim.fab_slide_in_from_right : R.anim.fab_slide_in_from_left);
    mLabelsHideAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_hideAnimation,
            mLabelsPosition == LABELS_POSITION_LEFT ? R.anim.fab_slide_out_to_right : R.anim.fab_slide_out_to_left);
    mLabelsPaddingTop = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingTop, mLabelsPaddingTop);
    mLabelsPaddingRight = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingRight, mLabelsPaddingRight);
    mLabelsPaddingBottom = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingBottom, mLabelsPaddingBottom);
    mLabelsPaddingLeft = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingLeft, mLabelsPaddingLeft);
    mLabelsTextColor = attr.getColorStateList(R.styleable.FloatingActionMenu_menu_labels_textColor);
    // set default value if null same as for textview
    if (mLabelsTextColor == null) {
        mLabelsTextColor = ColorStateList.valueOf(Color.WHITE);
    }
    mLabelsTextSize = attr.getDimension(R.styleable.FloatingActionMenu_menu_labels_textSize, getResources().getDimension(R.dimen.labels_text_size));
    mLabelsCornerRadius = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_cornerRadius, mLabelsCornerRadius);
    mLabelsShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_showShadow, true);
    mLabelsColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorNormal, 0xFF333333);
    mLabelsColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorPressed, 0xFF444444);
    mLabelsColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorRipple, 0x66FFFFFF);
    mMenuShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_showShadow, true);
    mMenuShadowColor = attr.getColor(R.styleable.FloatingActionMenu_menu_shadowColor, 0x66000000);
    mMenuShadowRadius = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowRadius, mMenuShadowRadius);
    mMenuShadowXOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowXOffset, mMenuShadowXOffset);
    mMenuShadowYOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowYOffset, mMenuShadowYOffset);
    mMenuColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_colorNormal, 0xFFDA4336);
    mMenuColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_colorPressed, 0xFFE75043);
    mMenuColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_colorRipple, 0x99FFFFFF);
    mAnimationDelayPerItem = attr.getInt(R.styleable.FloatingActionMenu_menu_animationDelayPerItem, 50);
    mIcon = attr.getDrawable(R.styleable.FloatingActionMenu_menu_icon);
    if (mIcon == null) {
        mIcon = getResources().getDrawable(R.drawable.fab_add);
    }
    mLabelsSingleLine = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_singleLine, false);
    mLabelsEllipsize = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_ellipsize, 0);
    mLabelsMaxLines = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_maxLines, -1);
    mMenuFabSize = attr.getInt(R.styleable.FloatingActionMenu_menu_fab_size, FloatingActionButton.SIZE_NORMAL);
    mLabelsStyle = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_style, 0);
    mOpenDirection = attr.getInt(R.styleable.FloatingActionMenu_menu_openDirection, OPEN_UP);
    mBackgroundColor = attr.getColor(R.styleable.FloatingActionMenu_menu_backgroundColor, Color.TRANSPARENT);

    if (attr.hasValue(R.styleable.FloatingActionMenu_menu_fab_label)) {
        mUsingMenuLabel = true;
        mMenuLabelText = attr.getString(R.styleable.FloatingActionMenu_menu_fab_label);
    }

    if (attr.hasValue(R.styleable.FloatingActionMenu_menu_labels_padding)) {
        int padding = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_padding, 0);
        initPadding(padding);
    }

    mOpenInterpolator = new OvershootInterpolator();
    mCloseInterpolator = new AnticipateInterpolator();
    mLabelsContext = new ContextThemeWrapper(getContext(), mLabelsStyle);

    initBackgroundDimAnimation();
    createMenuButton();
    initMenuButtonAnimations(attr);

    attr.recycle();
}