Java 类com.facebook.rebound.SpringListener 实例源码

项目:Backboard    文件:Actor.java   
/**
 * @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;
}
项目:Backboard    文件:Actor.java   
/**
 * 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);
}
项目:FloatWindow    文件:SpringConfiguratorView.java   
@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);
}
项目:MyScse-Client    文件:SpringConfiguratorView.java   
@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);
}
项目:Backboard    文件:Actor.java   
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;
}
项目:Backboard    文件:Actor.java   
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;
}
项目:Backboard    文件:Actor.java   
/**
 * 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);
            }
        }
    }
}
项目:Backboard    文件:Actor.java   
/**
 * 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);
            }
        }
    }
}
项目:Backboard    文件:Actor.java   
/**
 * @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 });
}
项目:KugouLayout    文件:SpringConfiguratorView.java   
@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);
}
项目:Green    文件:SpringConfiguratorView.java   
@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);
}
项目:ToggleButton    文件:SpringConfiguratorView.java   
@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);
}
项目:light-novel-library_Wenku8_Android    文件:SpringConfiguratorView.java   
@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);
}
项目:rebound    文件:SpringConfiguratorView.java   
@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);
}
项目:X-Alarm    文件:ReboundAnimation.java   
public Spring createSpringFromBouncinessAndSpeed(double bounciness, double speed, SpringListener springListener){
    return mSpringSystem.createSpring().setSpringConfig(
            SpringConfig.fromBouncinessAndSpeed(bounciness,speed))
            .addListener(springListener);
}
项目:Backboard    文件:Actor.java   
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);
}
项目:springy-heads    文件:ChatHead.java   
public SpringListener getHorizontalPositionListener() {
    return xPositionListener;
}
项目:springy-heads    文件:ChatHead.java   
public SpringListener getVerticalPositionListener() {
    return yPositionListener;
}
项目:Backboard    文件:Actor.java   
/**
 * 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 });
}
项目:Backboard    文件:Actor.java   
/**
 * @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;
}
项目:Backboard    文件:Actor.java   
/**
 * @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;
}