com.facebook.rebound.SpringListener Java Examples
The following examples show how to use
com.facebook.rebound.SpringListener.
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: Actor.java From Backboard with Apache License 2.0 | 6 votes |
/** * @param spring * the underlying {@link com.facebook.rebound.Spring}. * @param eventImitator * maps an event to a {@link com.facebook.rebound.Spring} * @param performers * map the {@link com.facebook.rebound.Spring} to a * {@link android.view.View} * @param springListeners * additional listeners to attach * @return the builder for chaining */ @NonNull public Builder addMotion(@NonNull final Spring spring, @NonNull final EventImitator eventImitator, @NonNull final Performer[] performers, final SpringListener[] springListeners) { // create struct final Motion motion = new Motion(spring, eventImitator, performers, springListeners); // connect actors motion.imitators[0].setSpring(motion.spring); for (Performer performer : motion.performers) { performer.setTarget(mView); } mMotions.add(motion); return this; }
Example #2
Source File: Actor.java From Backboard with Apache License 2.0 | 6 votes |
/** * Creations a new motion object. * * @param spring * the spring to use * @param motionProperties * the properties of the event to track * @param springListeners * additional spring listeners to add * @param trackStrategy * the tracking strategy * @param followStrategy * the follow strategy * @param restValue * the spring rest value * @return a motion object */ @Nullable private Motion createMotionFromProperties(@NonNull final Spring spring, @NonNull final MotionProperty[] motionProperties, @Nullable final SpringListener[] springListeners, final int trackStrategy, final int followStrategy, final int restValue) { final MotionImitator[] motionImitators = new MotionImitator[motionProperties.length]; final Performer[] performers = new Performer[motionProperties.length]; for (int i = 0; i < motionProperties.length; i++) { final MotionProperty property = motionProperties[i]; motionImitators[i] = new MotionImitator(spring, property, restValue, trackStrategy, followStrategy); performers[i] = new Performer(mView, property.getViewProperty()); } return new Motion(spring, motionImitators, performers, springListeners); }
Example #3
Source File: Actor.java From Backboard with Apache License 2.0 | 5 votes |
private Motion(@NonNull final Spring spring, @NonNull final Performer[] performers, @Nullable final SpringListener[] springListeners) { this.imitators = new MotionImitator[0]; this.performers = performers; this.spring = spring; this.springListeners = springListeners; }
Example #4
Source File: Actor.java From Backboard with Apache License 2.0 | 5 votes |
private Motion(@NonNull final Spring spring, @NonNull final EventImitator[] imitators, @NonNull final Performer[] performers, @Nullable final SpringListener[] springListeners) { this.imitators = imitators; this.performers = performers; this.spring = spring; this.springListeners = springListeners; }
Example #5
Source File: Actor.java From Backboard with Apache License 2.0 | 5 votes |
/** * Removes all spring listeners controlled by this {@link Actor}. */ public void removeAllListeners() { for (Motion motion : mMotions) { for (Performer performer : motion.performers) { motion.spring.removeListener(performer); } if (motion.springListeners != null) { for (SpringListener listener : motion.springListeners) { motion.spring.removeListener(listener); } } } }
Example #6
Source File: Actor.java From Backboard with Apache License 2.0 | 5 votes |
/** * Adds all spring listeners back. */ public void addAllListeners() { for (Motion motion : mMotions) { for (Performer performer : motion.performers) { motion.spring.addListener(performer); } if (motion.springListeners != null) { for (SpringListener listener : motion.springListeners) { motion.spring.addListener(listener); } } } }
Example #7
Source File: Actor.java From Backboard with Apache License 2.0 | 5 votes |
/** * @param motionImitator * maps an event to a {@link com.facebook.rebound.Spring} * @param viewProperty * the {@link android.view.View} property to animate * @param springListener * additional listener to attach * @return the builder for chaining */ @NonNull public Builder addMotion(@NonNull final MotionImitator motionImitator, @NonNull final Property<View, Float> viewProperty, final SpringListener springListener) { return addMotion(mSpringSystem.createSpring(), motionImitator, new Performer[] { new Performer(viewProperty) }, new SpringListener[] { springListener }); }
Example #8
Source File: SpringConfiguratorView.java From KugouLayout with MIT License | 5 votes |
@TargetApi(Build.VERSION_CODES.HONEYCOMB) public SpringConfiguratorView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); SpringSystem springSystem = SpringSystem.create(); springConfigRegistry = SpringConfigRegistry.getInstance(); spinnerAdapter = new SpinnerAdapter(context); Resources resources = getResources(); mRevealPx = dpToPx(40, resources); mStashPx = dpToPx(280, resources); mRevealerSpring = springSystem.createSpring(); SpringListener revealerSpringListener = new RevealerSpringListener(); mRevealerSpring .setCurrentValue(1) .setEndValue(1) .addListener(revealerSpringListener); addView(generateHierarchy(context)); SeekbarListener seekbarListener = new SeekbarListener(); mTensionSeekBar.setMax(MAX_SEEKBAR_VAL); mTensionSeekBar.setOnSeekBarChangeListener(seekbarListener); mFrictionSeekBar.setMax(MAX_SEEKBAR_VAL); mFrictionSeekBar.setOnSeekBarChangeListener(seekbarListener); mSpringSelectorSpinner.setAdapter(spinnerAdapter); mSpringSelectorSpinner.setOnItemSelectedListener(new SpringSelectedListener()); refreshSpringConfigurations(); this.setTranslationY(mStashPx); }
Example #9
Source File: SpringConfiguratorView.java From light-novel-library_Wenku8_Android with GNU General Public License v2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.HONEYCOMB) public SpringConfiguratorView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); SpringSystem springSystem = SpringSystem.create(); springConfigRegistry = SpringConfigRegistry.getInstance(); spinnerAdapter = new SpinnerAdapter(context); Resources resources = getResources(); mRevealPx = dpToPx(40, resources); mStashPx = dpToPx(280, resources); mRevealerSpring = springSystem.createSpring(); SpringListener revealerSpringListener = new RevealerSpringListener(); mRevealerSpring .setCurrentValue(1) .setEndValue(1) .addListener(revealerSpringListener); addView(generateHierarchy(context)); SeekbarListener seekbarListener = new SeekbarListener(); mTensionSeekBar.setMax(MAX_SEEKBAR_VAL); mTensionSeekBar.setOnSeekBarChangeListener(seekbarListener); mFrictionSeekBar.setMax(MAX_SEEKBAR_VAL); mFrictionSeekBar.setOnSeekBarChangeListener(seekbarListener); mSpringSelectorSpinner.setAdapter(spinnerAdapter); mSpringSelectorSpinner.setOnItemSelectedListener(new SpringSelectedListener()); refreshSpringConfigurations(); this.setTranslationY(mStashPx); }
Example #10
Source File: ReboundAnimation.java From X-Alarm with GNU Affero General Public License v3.0 | 4 votes |
public Spring createSpringFromBouncinessAndSpeed(double bounciness, double speed, SpringListener springListener){ return mSpringSystem.createSpring().setSpringConfig( SpringConfig.fromBouncinessAndSpeed(bounciness,speed)) .addListener(springListener); }
Example #11
Source File: Actor.java From Backboard with Apache License 2.0 | 4 votes |
private Motion(@NonNull final Spring spring, @NonNull final EventImitator imitator, @NonNull final Performer[] performers, @Nullable final SpringListener[] springListeners) { this(spring, new EventImitator[] { imitator }, performers, springListeners); }
Example #12
Source File: ChatHead.java From springy-heads with Apache License 2.0 | 4 votes |
public SpringListener getHorizontalPositionListener() { return xPositionListener; }
Example #13
Source File: ChatHead.java From springy-heads with Apache License 2.0 | 4 votes |
public SpringListener getVerticalPositionListener() { return yPositionListener; }
Example #14
Source File: Actor.java From Backboard with Apache License 2.0 | 3 votes |
/** * Uses the default {@link com.facebook.rebound.SpringConfig} to animate the view. * * @param property * the event field to imitate and the view property to animate. * @param listener * a listener to call * @return this builder for chaining */ @NonNull public Builder addTranslateMotion(final MotionProperty property, final SpringListener listener) { return addMotion(mSpringSystem.createSpring(), Imitator.TRACK_ABSOLUTE, Imitator.FOLLOW_EXACT, new MotionProperty[] { property }, new SpringListener[] { listener }); }
Example #15
Source File: Actor.java From Backboard with Apache License 2.0 | 3 votes |
/** * @param spring * the underlying {@link com.facebook.rebound.Spring}. * @param trackStrategy * the tracking behavior * @param followStrategy * the follow behavior * @param restValue * the rest value * @param property * the event fields to imitate and the view property to animate. * @param springListener * a spring listener to attach to the spring * @return this builder for chaining */ @NonNull public Builder addMotion(@NonNull final Spring spring, final int trackStrategy, final int followStrategy, final int restValue, final MotionProperty property, @Nullable final SpringListener springListener) { mMotions.add( createMotionFromProperties(spring, new MotionProperty[] { property }, new SpringListener[] { springListener }, trackStrategy, followStrategy, restValue)); return this; }
Example #16
Source File: Actor.java From Backboard with Apache License 2.0 | 3 votes |
/** * @param spring * the underlying {@link com.facebook.rebound.Spring}. * @param trackStrategy * the tracking behavior * @param followStrategy * the follow behavior * @param properties * the event fields to imitate and the view properties to animate. * @param springListeners * an array of spring listeners to attach to the spring * @return this builder for chaining */ @NonNull public Builder addMotion(@NonNull final Spring spring, final int trackStrategy, final int followStrategy, @NonNull final MotionProperty[] properties, final SpringListener[] springListeners) { mMotions.add( createMotionFromProperties(spring, properties, springListeners, trackStrategy, followStrategy, 0)); return this; }