本文整理汇总了Java中com.facebook.rebound.SpringUtil.mapValueFromRangeToRange方法的典型用法代码示例。如果您正苦于以下问题:Java SpringUtil.mapValueFromRangeToRange方法的具体用法?Java SpringUtil.mapValueFromRangeToRange怎么用?Java SpringUtil.mapValueFromRangeToRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.rebound.SpringUtil
的用法示例。
在下文中一共展示了SpringUtil.mapValueFromRangeToRange方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onSpringUpdate
import com.facebook.rebound.SpringUtil; //导入方法依赖的package包/类
@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);
}
示例2: onSpringUpdate
import com.facebook.rebound.SpringUtil; //导入方法依赖的package包/类
@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);
}
}
示例3: onSpringUpdate
import com.facebook.rebound.SpringUtil; //导入方法依赖的package包/类
@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);
}
}
示例4: onSpringUpdate
import com.facebook.rebound.SpringUtil; //导入方法依赖的package包/类
@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);
}
}
示例5: onSpringUpdate
import com.facebook.rebound.SpringUtil; //导入方法依赖的package包/类
@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);
}
示例6: calculateEffect
import com.facebook.rebound.SpringUtil; //导入方法依赖的package包/类
/**
* @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();
}
示例7: onSpringUpdate
import com.facebook.rebound.SpringUtil; //导入方法依赖的package包/类
@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);
}
示例8: onSpringUpdate
import com.facebook.rebound.SpringUtil; //导入方法依赖的package包/类
@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();
}
示例9: onSpringUpdate
import com.facebook.rebound.SpringUtil; //导入方法依赖的package包/类
/**
* 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 );
}
示例10: onSpringUpdate
import com.facebook.rebound.SpringUtil; //导入方法依赖的package包/类
@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);
}
}
示例11: onSpringUpdate
import com.facebook.rebound.SpringUtil; //导入方法依赖的package包/类
@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);
}
示例12: calculateEffect
import com.facebook.rebound.SpringUtil; //导入方法依赖的package包/类
/**
* @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();
}
示例13: render
import com.facebook.rebound.SpringUtil; //导入方法依赖的package包/类
/**
* 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);
}
示例14: onSpringUpdate
import com.facebook.rebound.SpringUtil; //导入方法依赖的package包/类
@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());
}
}
示例15: onSpringUpdate
import com.facebook.rebound.SpringUtil; //导入方法依赖的package包/类
@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);
}