Search in sources :

Example 6 with Spring

use of com.facebook.rebound.Spring in project android-card-slide-panel by xmuSistone.

the class CardItemView method initSpring.

private void initSpring() {
    SpringConfig springConfig = SpringConfig.fromBouncinessAndSpeed(15, 20);
    SpringSystem mSpringSystem = SpringSystem.create();
    springX = mSpringSystem.createSpring().setSpringConfig(springConfig);
    springY = mSpringSystem.createSpring().setSpringConfig(springConfig);
    springX.addListener(new SimpleSpringListener() {

        @Override
        public void onSpringUpdate(Spring spring) {
            int xPos = (int) spring.getCurrentValue();
            setScreenX(xPos);
            parentView.onViewPosChanged(CardItemView.this);
        }
    });
    springY.addListener(new SimpleSpringListener() {

        @Override
        public void onSpringUpdate(Spring spring) {
            int yPos = (int) spring.getCurrentValue();
            setScreenY(yPos);
            parentView.onViewPosChanged(CardItemView.this);
        }
    });
}
Also used : SimpleSpringListener(com.facebook.rebound.SimpleSpringListener) SpringConfig(com.facebook.rebound.SpringConfig) Spring(com.facebook.rebound.Spring) SpringSystem(com.facebook.rebound.SpringSystem)

Example 7 with Spring

use of com.facebook.rebound.Spring in project LollipopShowcase by mikepenz.

the class ReboundItemAnimator method runPendingAnimations.

@Override
public void runPendingAnimations() {
    if (!mViewHolders.isEmpty()) {
        for (final RecyclerView.ViewHolder viewHolder : mViewHolders) {
            SpringSystem springSystem = SpringSystem.create();
            SpringConfig springConfig = new SpringConfig(70, 10);
            final View target = viewHolder.itemView;
            // Add a spring to the system.
            Spring spring = springSystem.createSpring();
            spring.setSpringConfig(springConfig);
            spring.setCurrentValue(0.0f);
            // Add a listener to observe the motion of the spring.
            spring.addListener(new SimpleSpringListener() {

                @Override
                public void onSpringUpdate(Spring spring) {
                    // You can observe the updates in the spring
                    // state by asking its current value in onSpringUpdate.
                    float value = (float) spring.getCurrentValue();
                    target.setScaleX(value);
                    target.setScaleY(value);
                }
            });
            // Set the spring in motion; moving from 0 to 1
            spring.setEndValue(1.0f);
        }
    }
}
Also used : SimpleSpringListener(com.facebook.rebound.SimpleSpringListener) RecyclerView(android.support.v7.widget.RecyclerView) SpringConfig(com.facebook.rebound.SpringConfig) Spring(com.facebook.rebound.Spring) SpringSystem(com.facebook.rebound.SpringSystem) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 8 with Spring

use of com.facebook.rebound.Spring in project Depth-LIB-Android- by danielzeller.

the class RenderableThree method bounceBack.

public void bounceBack() {
    cancelBounce();
    isBounceAnimatin = true;
    spring = springSystem.createSpring();
    spring.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(150, 4));
    final float offsetAtStart = offsetInPercent;
    spring.addListener(new SimpleSpringListener() {

        @Override
        public void onSpringUpdate(Spring spring) {
            float value = (float) spring.getCurrentValue();
            offsetInPercent = offsetAtStart - (offsetAtStart * value);
        }

        @Override
        public void onSpringAtRest(Spring spring) {
            super.onSpringAtRest(spring);
            isBounceAnimatin = false;
        }
    });
    spring.setEndValue(1);
}
Also used : SimpleSpringListener(com.facebook.rebound.SimpleSpringListener) Spring(com.facebook.rebound.Spring)

Example 9 with Spring

use of com.facebook.rebound.Spring in project android_packages_apps_DUI by DirtyUnicorns.

the class BaseNavigationBar method flushSpringSystem.

public void flushSpringSystem() {
    if (mSpringSystem != null) {
        for (Spring spring : mSpringSystem.getAllSprings()) {
            spring.setAtRest();
            spring.removeAllListeners();
            spring.destroy();
        }
        mSpringSystem.removeAllListeners();
        mSpringSystem = null;
    }
}
Also used : Spring(com.facebook.rebound.Spring)

Example 10 with Spring

use of com.facebook.rebound.Spring in project android-adDialog by yipianfengye.

the class AnimSpring method startCircleAnim.

/**
     * 开始动画-定义动画开始角度
     * @param animType
     * @param animContainer
     */
public void startCircleAnim(final int animType, final RelativeLayout animContainer) {
    double radius = Math.sqrt(DisplayUtil.screenhightPx * DisplayUtil.screenhightPx + DisplayUtil.screenWidthPx * DisplayUtil.screenWidthPx);
    double heightY = -Math.sin(Math.toRadians(animType)) * radius;
    double widthX = Math.cos(Math.toRadians(animType)) * radius;
    Spring tranSpring = springSystem.createSpring();
    Spring tranSpring1 = springSystem.createSpring();
    tranSpring.addListener(new SimpleSpringListener() {

        @Override
        public void onSpringActivate(Spring spring) {
            animContainer.setVisibility(View.VISIBLE);
        }

        @Override
        public void onSpringUpdate(Spring spring) {
            animContainer.setTranslationX((float) spring.getCurrentValue());
        }
    });
    tranSpring1.addListener(new SimpleSpringListener() {

        @Override
        public void onSpringActivate(Spring spring) {
            animContainer.setVisibility(View.VISIBLE);
        }

        @Override
        public void onSpringUpdate(Spring spring) {
            animContainer.setTranslationY((float) spring.getCurrentValue());
        }
    });
    tranSpring.setSpringConfig(springConfig);
    tranSpring1.setSpringConfig(springConfig);
    tranSpring.setCurrentValue(widthX);
    tranSpring.setEndValue(0);
    tranSpring1.setCurrentValue(heightY);
    tranSpring1.setEndValue(0);
}
Also used : SimpleSpringListener(com.facebook.rebound.SimpleSpringListener) Spring(com.facebook.rebound.Spring)

Aggregations

Spring (com.facebook.rebound.Spring)18 SpringSystem (com.facebook.rebound.SpringSystem)11 View (android.view.View)10 SimpleSpringListener (com.facebook.rebound.SimpleSpringListener)7 Performer (com.tumblr.backboard.performer.Performer)5 SuppressLint (android.annotation.SuppressLint)3 TypedArray (android.content.res.TypedArray)3 RelativeLayout (android.widget.RelativeLayout)3 SpringConfig (com.facebook.rebound.SpringConfig)3 MotionEvent (android.view.MotionEvent)2 Actor (com.tumblr.backboard.Actor)2 ToggleImitator (com.tumblr.backboard.imitator.ToggleImitator)2 MapPerformer (com.tumblr.backboard.performer.MapPerformer)2 Point (android.graphics.Point)1 RecyclerView (android.support.v7.widget.RecyclerView)1 FrameLayout (android.widget.FrameLayout)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 Toast (android.widget.Toast)1 InjectView (butterknife.InjectView)1