com.facebook.rebound.SpringUtil Java Examples

The following examples show how to use com.facebook.rebound.SpringUtil. 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: MenuViewProxy.java    From RelaxFinger with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onSpringUpdate(Spring spring) {

    float mappedValue = (float) SpringUtil.mapValueFromRangeToRange(spring.getCurrentValue(), 0, 1, 1, 0.8);

    mMenuA.setScaleX(mappedValue);
    mMenuA.setScaleY(mappedValue);
    mMenuB.setScaleX(mappedValue);
    mMenuB.setScaleY(mappedValue);
    mMenuC.setScaleX(mappedValue);
    mMenuC.setScaleY(mappedValue);
    mMenuD.setScaleX(mappedValue);
    mMenuD.setScaleY(mappedValue);
    mMenuE.setScaleX(mappedValue);
    mMenuE.setScaleY(mappedValue);
}
 
Example #2
Source File: DraggerView.java    From Dragger with Apache License 2.0 5 votes vote down vote up
@Override public void onSpringUpdate(Spring spring) {

      double val = spring.getCurrentValue();
      switch (dragPosition) {
        case LEFT:
          ViewCompat.setTranslationX(dragView,
              (float) SpringUtil.mapValueFromRangeToRange(val, 0, 1, 0, -dragView.getWidth()));
          break;
        case RIGHT:
          ViewCompat.setTranslationX(dragView,
              (float) SpringUtil.mapValueFromRangeToRange(val, 0, 1, 0, dragView.getWidth()));
          break;
        case TOP:
          ViewCompat.setTranslationY(dragView,
              (float) SpringUtil.mapValueFromRangeToRange(val, 0, 1, 0, dragView.getHeight()));
          break;
        case BOTTOM:
          ViewCompat.setTranslationY(dragView,
              (float) SpringUtil.mapValueFromRangeToRange(val, 0, 1, 0, -dragView.getHeight()));
          break;
        default:
          break;
      }

      ViewCompat.setAlpha(shadowView,
          (float) (MAX_ALPHA - SpringUtil.mapValueFromRangeToRange(val, 0, 1, 0, 1)));

      if (draggerCallback != null) {
        draggerCallback.onProgress(spring.getCurrentValue());
      }
    }
 
Example #3
Source File: ToggleButton.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onSpringUpdate(Spring spring) {
	final double value = spring.getCurrentValue();
	
	final float mapToggleX = (float) SpringUtil.mapValueFromRangeToRange(value, 0, 1, spotMinX, spotMaxX);
	spotX = mapToggleX;
	
	float mapOffLineWidth = (float) SpringUtil.mapValueFromRangeToRange(1 - value, 0, 1, 10, spotSize);
	
	offLineWidth = mapOffLineWidth;
	
	final int fb = Color.blue(onColor);
	final int fr = Color.red(onColor);
	final int fg = Color.green(onColor);
	
	final int tb = Color.blue(offBorderColor);
	final int tr = Color.red(offBorderColor);
	final int tg = Color.green(offBorderColor);
	
	int sb = (int) SpringUtil.mapValueFromRangeToRange(1 - value, 0, 1, fb, tb);
	int sr = (int) SpringUtil.mapValueFromRangeToRange(1 - value, 0, 1, fr, tr);
	int sg = (int) SpringUtil.mapValueFromRangeToRange(1 - value, 0, 1, fg, tg);
	
	sb = clamp(sb, 0, 255);
	sr = clamp(sr, 0, 255);
	sg = clamp(sg, 0, 255);
	
	borderColor = Color.rgb(sr, sg, sb);
	
	postInvalidate();
}
 
Example #4
Source File: ToggleButton.java    From ToggleButton with MIT License 5 votes vote down vote up
/**
 * @param value
 */
private void calculateEffect(final double value) {
	final float mapToggleX = (float) SpringUtil.mapValueFromRangeToRange(value, 0, 1, spotMinX, spotMaxX);
	spotX = mapToggleX;
	
	float mapOffLineWidth = (float) SpringUtil.mapValueFromRangeToRange(1 - value, 0, 1, 10, spotSize);
	
	offLineWidth = mapOffLineWidth;
	
	final int fb = Color.blue(onColor);
	final int fr = Color.red(onColor);
	final int fg = Color.green(onColor);
	
	final int tb = Color.blue(offBorderColor);
	final int tr = Color.red(offBorderColor);
	final int tg = Color.green(offBorderColor);
	
	int sb = (int) SpringUtil.mapValueFromRangeToRange(1 - value, 0, 1, fb, tb);
	int sr = (int) SpringUtil.mapValueFromRangeToRange(1 - value, 0, 1, fr, tr);
	int sg = (int) SpringUtil.mapValueFromRangeToRange(1 - value, 0, 1, fg, tg);
	
	sb = clamp(sb, 0, 255);
	sr = clamp(sr, 0, 255);
	sg = clamp(sg, 0, 255);
	
	borderColor = Color.rgb(sr, sg, sb);
	
	postInvalidate();
}
 
Example #5
Source File: CountdownAnimationTextView.java    From AndroidPlayground with MIT License 5 votes vote down vote up
@Override
public void onSpringUpdate(Spring spring) {
    if (mView != null) {
        float mappedValue =
                (float) SpringUtil.mapValueFromRangeToRange(spring.getCurrentValue(), 0, 1,
                        1, TO_HIGH);
        mView.setScaleX(mappedValue);
        mView.setScaleY(mappedValue);
    }
}
 
Example #6
Source File: BonusAnimationActivity.java    From AndroidPlayground with MIT License 5 votes vote down vote up
@Override
public void onSpringUpdate(Spring spring) {
    float mappedValue =
            (float) SpringUtil.mapValueFromRangeToRange(spring.getCurrentValue(), 0, 1, 1,
                    1.5);
    if (mReference.get() != null && mReference.get().mBonusAnimationView != null) {
        mReference.get().mBonusAnimationView.setScaleX(mappedValue);
        mReference.get().mBonusAnimationView.setScaleY(mappedValue);
    }
    Log.d("BonusAnimTest", "mappedValue: " + mappedValue);
}
 
Example #7
Source File: PrismActivity.java    From PrismView with Apache License 2.0 5 votes vote down vote up
private void mainViewUpdate(double currentValue) {
  float ratio =  (float) SpringUtil.mapValueFromRangeToRange(currentValue, 0, 1,
      1, smallRatio);
  ViewCompat.setScaleX(mainView, ratio);
  ViewCompat.setScaleY(mainView, ratio);
  ViewCompat.setAlpha(mainView, ratio);
}
 
Example #8
Source File: PrismActivity.java    From PrismView with Apache License 2.0 5 votes vote down vote up
@Override public void onSpringUpdate(Spring spring) {
  super.onSpringUpdate(spring);
  double currentValue = spring.getCurrentValue();
  ViewCompat.setTranslationY(prismView,
      (float) SpringUtil.mapValueFromRangeToRange(currentValue, 0, 1,
          activityHelper.getHeight(), 0));
  mainViewUpdate(currentValue);
}
 
Example #9
Source File: PrismActivity.java    From PrismView with Apache License 2.0 5 votes vote down vote up
@Override public void onSpringUpdate(Spring spring) {
  super.onSpringUpdate(spring);
  double currentValue = spring.getCurrentValue();
  ViewCompat.setTranslationY(prismView,
      (float) SpringUtil.mapValueFromRangeToRange(currentValue, 0, 1,
          -activityHelper.getHeight(), 0));
  mainViewUpdate(currentValue);
}
 
Example #10
Source File: PrismActivity.java    From PrismView with Apache License 2.0 5 votes vote down vote up
@Override public void onSpringUpdate(Spring spring) {
  super.onSpringUpdate(spring);
  double currentValue = spring.getCurrentValue();
  ViewCompat.setTranslationX(prismView, (float) SpringUtil.mapValueFromRangeToRange(
      currentValue, 0, 1, -activityHelper.getWidth(), 0));
  mainViewUpdate(currentValue);
}
 
Example #11
Source File: PrismActivity.java    From PrismView with Apache License 2.0 5 votes vote down vote up
@Override public void onSpringUpdate(Spring spring) {
  super.onSpringUpdate(spring);
  double currentValue = spring.getCurrentValue();
  ViewCompat.setTranslationX(prismView, (float) SpringUtil.mapValueFromRangeToRange(
      currentValue, 0, 1, activityHelper.getWidth(), 0));
  mainViewUpdate(currentValue);
}
 
Example #12
Source File: SwitchButton.java    From FimiX8-RE with MIT License 5 votes vote down vote up
private void calculateEffect(double value) {
    this.spotX = (float) SpringUtil.mapValueFromRangeToRange(value, 0.0d, 1.0d, (double) this.spotMinX, (double) this.spotMaxX);
    float mapOffLineWidth = (float) SpringUtil.mapValueFromRangeToRange(1.0d - value, 0.0d, 1.0d, 10.0d, (double) this.spotSize);
    int spotFB = Color.blue(this.onSpotColor);
    int spotFR = Color.red(this.onSpotColor);
    int spotFG = Color.green(this.onSpotColor);
    int spotTB = Color.blue(this.offSpotColor);
    int spotTR = Color.red(this.offSpotColor);
    int spotSR = (int) SpringUtil.mapValueFromRangeToRange(1.0d - value, 0.0d, 1.0d, (double) spotFR, (double) spotTR);
    int spotSG = (int) SpringUtil.mapValueFromRangeToRange(1.0d - value, 0.0d, 1.0d, (double) spotFG, (double) Color.green(this.offSpotColor));
    int spotSB = clamp((int) SpringUtil.mapValueFromRangeToRange(1.0d - value, 0.0d, 1.0d, (double) spotFB, (double) spotTB), 0, 255);
    this.spotColor = Color.rgb(clamp(spotSR, 0, 255), clamp(spotSG, 0, 255), spotSB);
    postInvalidate();
}
 
Example #13
Source File: MapPerformer.java    From Backboard with Apache License 2.0 5 votes vote down vote up
@Override
public void onSpringUpdate(@NonNull final Spring spring) {

	mProperty.set(mTarget,
			(float) SpringUtil.mapValueFromRangeToRange(spring.getCurrentValue(),
					initialStart, initialEnd, start, end)
	);
}
 
Example #14
Source File: ReboundDemoActivity.java    From AndroidAnimations with Apache License 2.0 5 votes vote down vote up
@Override public void onSpringUpdate(Spring spring) {
  // On each update of the spring value, we adjust the scale of the image view to match the
  // springs new value. We use the SpringUtil linear interpolation function mapValueFromRangeToRange
  // to translate the spring's 0 to 1 scale to a 100% to 50% scale range and apply that to the View
  // with setScaleX/Y. Note that rendering is an implementation detail of the application and not
  // Rebound itself. If you need Gingerbread compatibility consider using NineOldAndroids to update
  // your view properties in a backwards compatible manner.
  float mappedValue = (float) SpringUtil.mapValueFromRangeToRange(spring.getCurrentValue(), 0, 1, 1, 0.5);
  imageView.setScaleX(mappedValue);
  imageView.setScaleY(mappedValue);
}
 
Example #15
Source File: YOLOComboView.java    From RxComboDetector with MIT License 5 votes vote down vote up
@Override
public void onSpringUpdate(Spring spring) {
    if (mView != null) {
        float mappedValue =
                (float) SpringUtil.mapValueFromRangeToRange(spring.getCurrentValue(), 0, 1,
                        1, TO_HIGH);
        mView.setScaleX(mappedValue);
        mView.setScaleY(mappedValue);
    }
}
 
Example #16
Source File: ChatHeadCloseButton.java    From springy-heads with Apache License 2.0 4 votes vote down vote up
private double getTranslationFromSpring(double springValue, float percent, int fullValue) {
    float widthToCover = percent * fullValue;
    return SpringUtil.mapValueFromRangeToRange(springValue, 0, fullValue, -widthToCover / 2, widthToCover / 2);
}
 
Example #17
Source File: CallAvatarLayerAnimator.java    From actor-platform with GNU Affero General Public License v3.0 4 votes vote down vote up
private float transition (float progress, float startValue, float endValue) {
    return (float) SpringUtil.mapValueFromRangeToRange(progress, 0, 1, startValue, endValue);
}
 
Example #18
Source File: BaseSpringListener.java    From X-Alarm with GNU Affero General Public License v3.0 4 votes vote down vote up
public float transition(float progress, float startValue, float endValue) {
    return (float) SpringUtil.mapValueFromRangeToRange(progress, 0, 1, startValue, endValue);
}
 
Example #19
Source File: SetAlarmActivity.java    From X-Alarm with GNU Affero General Public License v3.0 4 votes vote down vote up
protected float transition(float progress, float startValue, float endValue) {
    return (float) SpringUtil.mapValueFromRangeToRange(progress, 0, 1, startValue, endValue);
}
 
Example #20
Source File: ReboundAnimDialogFragment.java    From YummyTextSwitcher with MIT License 4 votes vote down vote up
private float transition(float progress, float startValue, float endValue) {
    return (float) SpringUtil.mapValueFromRangeToRange(progress, 0, 1, startValue, endValue);
}
 
Example #21
Source File: YumFloating.java    From FloatingView with Apache License 2.0 4 votes vote down vote up
@Override
public float transition(double progress, float startValue, float endValue) {
    return (float) SpringUtil.mapValueFromRangeToRange(progress, 0, 1, startValue, endValue);
}
 
Example #22
Source File: SpringHelper.java    From FloatingView with Apache License 2.0 4 votes vote down vote up
public float transition(double progress, float startValue, float endValue) {
    return (float) SpringUtil.mapValueFromRangeToRange(progress, 0, 1, startValue, endValue);
}