Example usage for android.view.animation LinearInterpolator LinearInterpolator

List of usage examples for android.view.animation LinearInterpolator LinearInterpolator

Introduction

In this page you can find the example usage for android.view.animation LinearInterpolator LinearInterpolator.

Prototype

public LinearInterpolator() 

Source Link

Usage

From source file:com.dbeginc.dbweather.utils.animations.widgets.RainFallView.java

@Override
protected void onSizeChanged(int width, int height, int oldWidth, int oldHeight) {
    super.onSizeChanged(width, height, oldWidth, oldHeight);
    SecureRandom random = new SecureRandom();
    Interpolator interpolator = new LinearInterpolator();

    mRainFlakeCount = Math.max(width, height) / 20;
    coords = new int[mRainFlakeCount][];
    drawables.clear();//  w  w w . j av  a  2  s.c om
    for (int i = 0; i < mRainFlakeCount; i++) {
        Animation animation = new TranslateAnimation(0, height / 10 - random.nextInt(height / 5), 0,
                height + 30);
        animation.setDuration(10 * height + random.nextInt(5 * height));
        animation.setRepeatCount(-1);
        animation.initialize(10, 10, 10, 10);
        animation.setInterpolator(interpolator);

        coords[i] = new int[] { random.nextInt(width - 30), -30 };

        drawables.add(new AnimateDrawable(mRainDrop, animation));
        animation.setStartOffset(random.nextInt(20 * height));
        animation.startNow();
        int y;
        y = random.nextInt(2);
        if (y == 0) {
            drawables.add(new AnimateDrawable(mRainDrop, animation));
        } else {
            drawables.add(new AnimateDrawable(mRainDrop));
        }
    }
}

From source file:com.dbeginc.dbweather.utils.animations.widgets.SnowFallView.java

@Override
protected void onSizeChanged(int width, int height, int oldWidth, int oldHeight) {
    super.onSizeChanged(width, height, oldWidth, oldHeight);
    Random random = new SecureRandom();
    Interpolator interpolator = new LinearInterpolator();

    snow_flake_count = Math.max(width, height) / 20;
    coords = new int[snow_flake_count][];
    drawables.clear();/*w  w w.  j  a  v a 2s.co  m*/
    for (int i = 0; i < snow_flake_count; i++) {
        Animation animation = new TranslateAnimation(0, height / 10 - random.nextInt(height / 5), 0,
                height + 30);
        animation.setDuration(10 * height + random.nextInt(5 * height));
        animation.setRepeatCount(-1);
        animation.initialize(10, 10, 10, 10);
        animation.setInterpolator(interpolator);

        coords[i] = new int[] { random.nextInt(width - 30), -30 };

        drawables.add(new AnimateDrawable(snow_flake, animation));
        animation.setStartOffset(random.nextInt(20 * height));
        animation.startNow();
        int y;
        y = random.nextInt(2);
        if (y == 0) {
            drawables.add(new AnimateDrawable(snow_flake, animation));
        } else {
            drawables.add(new AnimateDrawable(snow_flake));
        }
    }
}

From source file:com.bobomee.android.navigator.expandable.Utils.java

/**
 * Creates interpolator.// w w  w .  j av  a2 s .c o m
 * @return  a timeinterpolator
 * @param interpolatorType a int value from 0 to 10
 */
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();
    }
}

From source file:com.mokee.setupwizard.SetupWizardActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    checkInit();/* ww w .j a v  a  2 s.  com*/
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    mStatusBarManager = (StatusBarManager) getSystemService(Context.STATUS_BAR_SERVICE);
    disableStatusBar();

    sInterpolator = new LinearInterpolator();
    mViewPager = (ViewPager) findViewById(R.id.pager);
    getPages();

    mViewPager.setAdapter(new MkFragmentAdapter(getFragmentManager()));
    mViewPager.setPageTransformer(true, new DepthPageTransformer());
    mViewPager.setCurrentItem(0);
    mViewPager.setOnPageChangeListener(mPagerListener);

    try {
        Field mScroller;
        mScroller = ViewPager.class.getDeclaredField("mScroller");
        mScroller.setAccessible(true);
        FixedSpeedScroller scroller = new FixedSpeedScroller(mViewPager.getContext(), sInterpolator);
        scroller.setFixedDuration(200);
        mScroller.set(mViewPager, scroller);
    } catch (NoSuchFieldException e) {
    } catch (IllegalArgumentException e) {
    } catch (IllegalAccessException e) {
    }
}

From source file:com.canyinghao.canrefresh.classic.RotateRefreshView.java

@Override
protected void onFinishInflate() {
    super.onFinishInflate();

    ivRotate = (ImageView) findViewById(R.id.ivRotate);

    ivRotate.setScaleType(ScaleType.MATRIX);

    mRotateAnimation.setInterpolator(new LinearInterpolator());
    mRotateAnimation.setDuration(ROTATION_ANIMATION_DURATION);
    mRotateAnimation.setRepeatCount(Animation.INFINITE);
    mRotateAnimation.setRepeatMode(Animation.RESTART);

}

From source file:com.hippo.anani.AnimationUtils.java

private static Interpolator createInterpolatorFromXml(Context context, XmlPullParser parser)
        throws XmlPullParserException, IOException {

    Interpolator interpolator = null;//w  w w.  j a v a2s . c om

    // Make sure we are on a start tag.
    int type;
    int depth = parser.getDepth();

    while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth)
            && type != XmlPullParser.END_DOCUMENT) {

        if (type != XmlPullParser.START_TAG) {
            continue;
        }

        AttributeSet attrs = Xml.asAttributeSet(parser);

        String name = parser.getName();

        if (name.equals("linearInterpolator")) {
            interpolator = new LinearInterpolator();
        } else if (name.equals("accelerateInterpolator")) {
            interpolator = new AccelerateInterpolator(context, attrs);
        } else if (name.equals("decelerateInterpolator")) {
            interpolator = new DecelerateInterpolator(context, attrs);
        } else if (name.equals("accelerateDecelerateInterpolator")) {
            interpolator = new AccelerateDecelerateInterpolator();
        } else if (name.equals("cycleInterpolator")) {
            interpolator = new CycleInterpolator(context, attrs);
        } else if (name.equals("anticipateInterpolator")) {
            interpolator = new AnticipateInterpolator(context, attrs);
        } else if (name.equals("overshootInterpolator")) {
            interpolator = new OvershootInterpolator(context, attrs);
        } else if (name.equals("anticipateOvershootInterpolator")) {
            interpolator = new AnticipateOvershootInterpolator(context, attrs);
        } else if (name.equals("bounceInterpolator")) {
            interpolator = new BounceInterpolator();
        } else if (name.equals("pathInterpolator")) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                interpolator = new android.view.animation.PathInterpolator(context, attrs);
            } else {
                interpolator = new PathInterpolator(context, attrs);
            }
        } else {
            throw new RuntimeException("Unknown interpolator name: " + parser.getName());
        }
    }
    return interpolator;
}

From source file:com.idreamsky.dreamroom.ui.custum.CatLoadingView.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (mDialog == null) {
        mDialog = new Dialog(getActivity(), R.style.cart_dialog);
        mDialog.setContentView(R.layout.catloading_main);
        mDialog.setCanceledOnTouchOutside(true);
        mDialog.getWindow().setGravity(Gravity.CENTER);

        operatingAnim = new RotateAnimation(360f, 0f, Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f);
        operatingAnim.setRepeatCount(Animation.INFINITE);
        operatingAnim.setDuration(2000);

        eye_left_Anim = new RotateAnimation(360f, 0f, Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f);
        eye_left_Anim.setRepeatCount(Animation.INFINITE);
        eye_left_Anim.setDuration(2000);

        eye_right_Anim = new RotateAnimation(360f, 0f, Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f);
        eye_right_Anim.setRepeatCount(Animation.INFINITE);
        eye_right_Anim.setDuration(2000);

        LinearInterpolator lin = new LinearInterpolator();
        operatingAnim.setInterpolator(lin);
        eye_left_Anim.setInterpolator(lin);
        eye_right_Anim.setInterpolator(lin);

        View view = mDialog.getWindow().getDecorView();

        mouse = view.findViewById(R.id.mouse);

        eye_left = view.findViewById(R.id.eye_left);

        eye_right = view.findViewById(R.id.eye_right);

        eyelid_left = (EyelidView) view.findViewById(R.id.eyelid_left);

        eyelid_left.setColor(Color.parseColor("#d0ced1"));

        eyelid_left.setFromFull(true);//www  .  j  a v a 2  s.  co m

        eyelid_right = (EyelidView) view.findViewById(R.id.eyelid_right);

        eyelid_right.setColor(Color.parseColor("#d0ced1"));

        eyelid_right.setFromFull(true);

        mGraduallyTextView = (GraduallyTextView) view.findViewById(R.id.graduallyTextView);

        operatingAnim.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
            }

            @Override
            public void onAnimationEnd(Animation animation) {
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
                eyelid_left.resetAnimator();
                eyelid_right.resetAnimator();
            }
        });
    }
    return mDialog;
}

From source file:com.coco.rolldigitaltextview.RollDigitalTextView.java

private void initRollDigitalTextView() {
    final Context context = getContext();
    mScroller = new Scroller(context, new LinearInterpolator());
}

From source file:org.runbuddy.tomahawk.views.SimplePagerIndicator.java

public void setViewPager(final ViewPager viewPager) {
    removeAllViews();/*from   w  w w.  ja  v  a 2  s. co  m*/
    viewPager.addOnPageChangeListener(mOnPageChangeListener);
    mItemCount = viewPager.getAdapter().getCount();
    ViewUtils.afterViewGlobalLayout(new ViewUtils.ViewRunnable(this) {
        @Override
        public void run() {
            View tabIndicator = LayoutInflater.from(getContext())
                    .inflate(R.layout.simplepagertabs_tab_indicator, SimplePagerIndicator.this, false);
            tabIndicator.getLayoutParams().width = getLayedOutView().getWidth() / mItemCount;
            addView(tabIndicator);
            int xGoal = getLayedOutView().getWidth() - getLayedOutView().getWidth() / mItemCount;
            mAnimator = ObjectAnimator.ofFloat(tabIndicator, "x", 0, xGoal);
            mAnimator.setInterpolator(new LinearInterpolator());
            mAnimator.setDuration(10000);
        }
    });
}

From source file:org.tomahawk.tomahawk_android.views.SimplePagerIndicator.java

public void setViewPager(final ViewPager viewPager) {
    removeAllViews();/*from  ww  w . j  a  v  a  2 s  .  c  om*/
    viewPager.setOnPageChangeListener(mOnPageChangeListener);
    mItemCount = viewPager.getAdapter().getCount();
    ViewUtils.afterViewGlobalLayout(new ViewUtils.ViewRunnable(this) {
        @Override
        public void run() {
            View tabIndicator = LayoutInflater.from(getContext())
                    .inflate(R.layout.simplepagertabs_tab_indicator, SimplePagerIndicator.this, false);
            tabIndicator.getLayoutParams().width = getLayedOutView().getWidth() / mItemCount;
            addView(tabIndicator);
            int xGoal = getLayedOutView().getWidth() - getLayedOutView().getWidth() / mItemCount;
            mAnimator = ObjectAnimator.ofFloat(tabIndicator, "x", 0, xGoal);
            mAnimator.setInterpolator(new LinearInterpolator());
            mAnimator.setDuration(10000);
        }
    });
}