@Override public void onBackPressed() { if (mAnimating || mCurrentExample == null) { return; } mAnimating = true; mCurrentExample.hide(true, new ExampleContainerView.Callback() { @Override public void onProgress(double progress) { float scale = (float) SpringUtil.mapValueFromRangeToRange(progress, 0, 1, 0.8, 1); mRootContainer.setScaleX(scale); mRootContainer.setScaleY(scale); mRootContainer.setAlpha((float) progress); } @Override public void onEnd() { mAnimating = false; mCurrentExample.clearCallback(); mRootView.removeView(mCurrentExample); mCurrentExample = null; } }); }
@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); mImageView.setScaleX(mappedValue); mImageView.setScaleY(mappedValue); }
@Override public void onSpringUpdate(Spring spring) { setVisibility(View.VISIBLE); double value = spring.getCurrentValue(); float selectedImage = (float) SpringUtil.mapValueFromRangeToRange( value, 0, 1, 0, 1); float titleTranslateX = (float) SpringUtil.mapValueFromRangeToRange( value, 0, 1, mStartX, 0); float titleTranslateY = (float) SpringUtil.mapValueFromRangeToRange( value, 0, 1, mStartY, 0); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { setScaleX(selectedImage); setScaleY(selectedImage); setTranslationX(titleTranslateX); setTranslationY(titleTranslateY); } }
@Override public void onSpringUpdate(Spring spring) { setVisibility(View.VISIBLE); double value = spring.getCurrentValue(); float selectedTitleScale = (float) SpringUtil.mapValueFromRangeToRange( value, 0, 1, 0, 1); float titleTranslateX = (float) SpringUtil.mapValueFromRangeToRange( value, 0, 1, mStartX, 0); float titleTranslateY = (float) SpringUtil.mapValueFromRangeToRange( value, 0, 1, mStartY, 0); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { setScaleX(selectedTitleScale); setScaleY(selectedTitleScale); setTranslationX(titleTranslateX); setTranslationY(titleTranslateY); } }
@Override public void onSpringUpdate(Spring spring) { Resources resources = getResources(); double value = spring.getCurrentValue(); float selectedTitleScale = (float) SpringUtil.mapValueFromRangeToRange(value, 0, 1, 0, 1); float titleTranslateY = (float) SpringUtil.mapValueFromRangeToRange(value, 0, 1, Util.dpToPx(-150f, resources), 0); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { setScaleX(selectedTitleScale); setScaleY(selectedTitleScale); setTranslationY(titleTranslateY); } }
@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); suggestionView.setScaleX(mappedValue); suggestionView.setScaleY(mappedValue); }
/** * @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(); }
@Override public void onSpringUpdate(Spring spring) { float mappedvalue = (float) SpringUtil.mapValueFromRangeToRange(spring.getCurrentValue(), 0, 1, 1, 0.8); view.setScaleX(mappedvalue); view.setScaleY(mappedvalue); float rotation = (float) SpringUtil.mapValueFromRangeToRange(spring.getCurrentValue(), 0, 1, 0, 30); view.setRotation(rotation); }
@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(); }
/** * Called whenever the spring is updated * * @param spring the Spring sending the update */ @Override public void onSpringUpdate( Spring spring ) { /* Map our current value to scale values. Rebound has a nifty SpringUtil class to do that We map our values between scale 0.3 to 1 (Range of 30% to 100%) */ double nMappedValue = SpringUtil.mapValueFromRangeToRange( spring.getCurrentValue(), 0.0d, 1.0d, 0.8d, 1.0d); mView.get().setScaleX( (float)nMappedValue ); mView.get().setScaleY( (float)nMappedValue ); }
@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); } }
@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); }
/** * This method takes the current state of the spring and maps it to all the values for each UI * element that is animated on this spring. This allows the Spring to act as a common timing * function for the animation ensuring that all element transitions are synchronized. * * You can think of these mappings as similiar to Origami transitions. * SpringUtil#mapValueFromRangeToRange converts the spring's 0 to 1 transition and maps it to the * range of animation for a property on a view such as translation, scale, rotation, and alpha. */ private void render() { Resources resources = getResources(); // Get the current spring value. double value = mSpring.getCurrentValue(); // Map the spring to the feedback bar position so that its hidden off screen and bounces in on tap. float barPosition = (float) SpringUtil.mapValueFromRangeToRange(value, 0, 1, mFeedbackBar.getHeight(), 0); mFeedbackBar.setTranslationY(barPosition); // Map the spring to the selected photo scale as it moves into and out of the grid. float selectedPhotoScale = (float) SpringUtil.mapValueFromRangeToRange(value, 0, 1, 0.33, 1); selectedPhotoScale = Math.max(selectedPhotoScale, 0); // Clamp the value so we don't go below 0. mSelectedPhoto.setScaleX(selectedPhotoScale); mSelectedPhoto.setScaleY(selectedPhotoScale); // Map the spring to the selected photo translation from its position in the grid float selectedPhotoTranslateX = (float) SpringUtil.mapValueFromRangeToRange(value, 0, 1, Util.dpToPx(-106.667f, resources), 0); float selectedPhotoTranslateY = (float) SpringUtil.mapValueFromRangeToRange(value, 0, 1, Util.dpToPx(46.667f, resources), 0); mSelectedPhoto.setTranslationX(selectedPhotoTranslateX); mSelectedPhoto.setTranslationY(selectedPhotoTranslateY); // Map the spring to the photo grid alpha as it fades to black when the photo is selected. float gridAlpha = (float) SpringUtil.mapValueFromRangeToRange(value, 0, 1, 1, 0); mPhotoGrid.setAlpha(gridAlpha); // Map the spring to the photo grid scale so that it scales down slightly as the selected photo // zooms in. float gridScale = (float) SpringUtil.mapValueFromRangeToRange(value, 0, 1, 1, 0.95); gridScale = Math.max(gridScale, 0); // Clamp the value so we don't go below 0. mPhotoGrid.setScaleX(gridScale); mPhotoGrid.setScaleY(gridScale); }
@Override public void onSpringUpdate(Spring spring) { double val = spring.getCurrentValue(); float xlat = (float) SpringUtil.mapValueFromRangeToRange(val, 0, 1, 0, getWidth()); setTranslationX(xlat); if (mCallback != null) { mCallback.onProgress(spring.getCurrentValue()); } }
@Override public void onSpringUpdate(@NonNull final Spring spring) { mProperty.set(mTarget, (float) SpringUtil.mapValueFromRangeToRange(spring.getCurrentValue(), initialStart, initialEnd, start, end) ); }
@Override public void onSpringUpdate(Spring spring) { super.onSpringUpdate(spring); val = spring.getCurrentValue(); ViewCompat.setTranslationX(viewCallback.getFabButton(), (float) SpringUtil.mapValueFromRangeToRange(val, 0, 1, 0, centerX + 100)); ViewCompat.setTranslationY(viewCallback.getFabButton(), (float) SpringUtil.mapValueFromRangeToRange(val, 0, 1, 0, centerY + 100)); ViewCompat.setTranslationX(viewCallback.getBoundMenu(), (float) SpringUtil.mapValueFromRangeToRange(val, 0, 1, 0, centerX + 100)); ViewCompat.setTranslationY(viewCallback.getBoundMenu(), (float) SpringUtil.mapValueFromRangeToRange(val, 0, 1, 0, centerY )); }
@Override public void onSpringUpdate(Spring spring) { super.onSpringUpdate(spring); float scaleSpring = (float) SpringUtil.mapValueFromRangeToRange( spring.getCurrentValue(), 0, 1, 0, scale); ViewCompat.setScaleX(viewCallback.getBoundMenu(), scaleSpring); ViewCompat.setScaleY(viewCallback.getBoundMenu(), scaleSpring); }
@Override public void onSpringUpdate(Spring spring) { super.onSpringUpdate(spring); rotateHorizontal = (float) SpringUtil.mapValueFromRangeToRange(spring.getCurrentValue(), 0, 1, 0, 180); if(rotateHorizontal > 90) { frontCreditCardView.setVisibility(GONE); backCreditCardView.setVisibility(VISIBLE); } else { frontCreditCardView.setVisibility(VISIBLE); backCreditCardView.setVisibility(GONE); } ViewCompat.setRotationY(frontCreditCardView, rotateHorizontal); ViewCompat.setRotationY(backCreditCardView, 180 - rotateHorizontal); }
@Override public void onSpringUpdate(Spring spring) { super.onSpringUpdate(spring); verticalCurrentValue = spring.getCurrentValue(); float rotation = (float) SpringUtil.mapValueFromRangeToRange(verticalCurrentValue, 0, 1, 0, -30); ViewCompat.setRotationX(frontCreditCardView, rotation); ViewCompat.setRotationX(backCreditCardView, rotation); float scale = (float) SpringUtil.mapValueFromRangeToRange(verticalCurrentValue, 0, 1, 1, 0.7); ViewCompat.setScaleX(frontCreditCardView, scale); ViewCompat.setScaleY(frontCreditCardView, scale); ViewCompat.setScaleX(backCreditCardView, scale); ViewCompat.setScaleY(backCreditCardView, scale); if(bottomView != null) { int creditCardHeight = frontCreditCardView.getHeight(); float cardPositionY = (float) SpringUtil.mapValueFromRangeToRange(verticalCurrentValue, 0, 1, 0, -(creditCardHeight / 6.5)); ViewCompat.setTranslationY(frontCreditCardView, cardPositionY); ViewCompat.setTranslationY(backCreditCardView, cardPositionY); ViewCompat.setTranslationY(bottomView, (float) SpringUtil.mapValueFromRangeToRange(verticalCurrentValue, 0, 1, 0, -(creditCardHeight / 2.5))); } }
@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()); } }
@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); }
@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); }
@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); }
@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); }
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); }
@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); }
@Override public void onSpringUpdate(Spring spring) { float mappedValue = (float) SpringUtil.mapValueFromRangeToRange(spring.getCurrentValue(), 0, 1, 1, 0.5); imagen.setScaleX(mappedValue); imagen.setScaleY(mappedValue); }