本文整理匯總了Java中com.facebook.rebound.Spring類的典型用法代碼示例。如果您正苦於以下問題:Java Spring類的具體用法?Java Spring怎麽用?Java Spring使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Spring類屬於com.facebook.rebound包,在下文中一共展示了Spring類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setSpringSystem
import com.facebook.rebound.Spring; //導入依賴的package包/類
private void setSpringSystem() {
mSpringSystem = SpringSystem.create();
mSpringsAlpha = mSpringSystem.createSpring()
.setSpringConfig(alphaconfig)
.setCurrentValue(1);
mSpringsAlpha.addListener(new SimpleSpringListener() {
@Override
public void onSpringUpdate(Spring mSpring) {
float value = (float) mSpring.getCurrentValue();
mLockView.setAlpha(value);
}
});
}
示例2: applyBloomOpenAnimation
import com.facebook.rebound.Spring; //導入依賴的package包/類
private void applyBloomOpenAnimation() {
final SpringSystem springSystem = SpringSystem.create();
for (int i = 0; i < mMenuItemCount; i++) {
// create the springs that control movement
final Spring springX = springSystem.createSpring();
final Spring springY = springSystem.createSpring();
MenuItemView menuItemView = mMenuItemViews.get(i);
springX.addListener(new MapPerformer(menuItemView, View.X, mFAB.getLeft(), menuItemView.getLeft()));
springY.addListener(new MapPerformer(menuItemView, View.Y, mFAB.getTop(), menuItemView.getTop()));
DestroySelfSpringListener destroySelfSpringListener = new DestroySelfSpringListener(this,mContainerView,true);
springX.addListener(destroySelfSpringListener);
springY.addListener(destroySelfSpringListener);
springX.setEndValue(1);
springY.setEndValue(1);
}
}
示例3: applyBloomCloseAnimation
import com.facebook.rebound.Spring; //導入依賴的package包/類
private void applyBloomCloseAnimation() {
final SpringSystem springSystem = SpringSystem.create();
for (int i = 0; i < mMenuItemCount; i++) {
// create the springs that control movement
final Spring springX = springSystem.createSpring();
final Spring springY = springSystem.createSpring();
MenuItemView menuItemView = mMenuItemViews.get(i);
springX.addListener(new MapPerformer(menuItemView, View.X, menuItemView.getLeft(), mFAB.getLeft()));
springY.addListener(new MapPerformer(menuItemView, View.Y, menuItemView.getTop(), mFAB.getTop()));
DestroySelfSpringListener destroySelfSpringListener = new DestroySelfSpringListener(this,mContainerView,false);
springX.addListener(destroySelfSpringListener);
springY.addListener(destroySelfSpringListener);
springX.setEndValue(1);
springY.setEndValue(1);
}
}
示例4: applyPressAnimation
import com.facebook.rebound.Spring; //導入依賴的package包/類
private void applyPressAnimation() {
SpringSystem springSystem = SpringSystem.create();
final Spring spring = springSystem.createSpring();
spring.addListener(new Performer(mBtn, View.SCALE_X));
spring.addListener(new Performer(mBtn, View.SCALE_Y));
mBtn.setOnTouchListener(new ToggleImitator(spring, 1, 1.2){
@Override
public void imitate(MotionEvent event) {
super.imitate(event);
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
break;
case MotionEvent.ACTION_UP:
callOnClick();
break;
default:
}
}
});
spring.setCurrentValue(1);
}
示例5: bounceView
import com.facebook.rebound.Spring; //導入依賴的package包/類
/**
* Bounce the view. Will use the respective values for center and radial view
* @param child
* The child that has to be bounced
* @param springAnimator
* The spring animator with the listener to be invoked.
* Set null if you dont need to intercept the spring animation end
*
* @author Melvin Lobo
*/
private void bounceView(View child, SpringAnimator springAnimator) {
LayoutParams params = (LayoutParams) child.getLayoutParams();
if(params.getMenuType() == LayoutParams.CENTER) {
Spring centerScaleSpring = mSpringSystem.createSpring();
centerScaleSpring.setSpringConfig( new SpringConfig( CENTER_SCALE_TENSION, CENTER_SCALE_FRICTION ) );
centerScaleSpring.setEndValue( 1 );
centerScaleSpring.addListener( springAnimator );
}
else {
Spring radialScaleSpring = mSpringSystem.createSpring();
radialScaleSpring.setSpringConfig( new SpringConfig( RADIAL_SCALE_TENSION, RADIAL_SCALE_FRICTION ) );
radialScaleSpring.setEndValue( 1 );
radialScaleSpring.addListener( springAnimator );
}
}
示例6: onSpringUpdate
import com.facebook.rebound.Spring; //導入依賴的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);
}
示例7: addMotion
import com.facebook.rebound.Spring; //導入依賴的package包/類
/**
* @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}
* @return the builder for chaining
*/
@NonNull
public Builder addMotion(@NonNull final Spring spring, @NonNull final EventImitator eventImitator,
@NonNull final Performer... performers) {
final Motion motion = new Motion(spring, eventImitator, performers, null);
// connect actors
motion.imitators[0].setSpring(motion.spring);
for (Performer performer : motion.performers) {
performer.setTarget(mView);
}
mMotions.add(motion);
return this;
}
示例8: togglePosition
import com.facebook.rebound.Spring; //導入依賴的package包/類
private void togglePosition() {
double d = PathListView.NO_ZOOM;
double currentValue = this.mRevealerSpring.getEndValue();
Spring spring = this.mRevealerSpring;
if (currentValue == PathListView.NO_ZOOM) {
d = 0.0d;
}
spring.setEndValue(d);
}
示例9: start
import com.facebook.rebound.Spring; //導入依賴的package包/類
public void start(){
SpringSystem springSystem = SpringSystem.create();
Spring spring = springSystem.createSpring();
if (mConfig == 0){
spring.setSpringConfig(SpringConfig.fromBouncinessAndSpeed(mConfigValueOne, mConfigValueTwo));
}else if (mConfig == 1){
spring.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(mConfigValueOne, mConfigValueTwo));
}
start(spring);
}
示例10: onSpringUpdate
import com.facebook.rebound.Spring; //導入依賴的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);
}
示例11: onSpringUpdate
import com.facebook.rebound.Spring; //導入依賴的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);
}
示例12: onSpringUpdate
import com.facebook.rebound.Spring; //導入依賴的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();
}
示例13: onSpringUpdate
import com.facebook.rebound.Spring; //導入依賴的package包/類
@Override
public void onSpringUpdate(Spring spring) {
float value = (float) spring.getCurrentValue();
float scale = 1f - (value * 0.5f);
view.setScaleX(scale);
view.setScaleY(scale);
}
示例14: showLabel
import com.facebook.rebound.Spring; //導入依賴的package包/類
public void showLabel() {
SpringSystem springSystem = SpringSystem.create();
final Spring spring = springSystem.createSpring();
spring.addListener(new MapPerformer(mLabel, View.SCALE_X, 0, 1));
spring.addListener(new MapPerformer(mLabel, View.SCALE_Y, 0, 1));
spring.setCurrentValue(0);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
spring.setEndValue(1);
}
}, 200);
}
示例15: onSpringAtRest
import com.facebook.rebound.Spring; //導入依賴的package包/類
@Override
public void onSpringAtRest(Spring spring) {
spring.removeAllListeners();
spring.destroy();
spring = null;
if(mSpringMenu != null && !mInOpen) {
mSpringMenu.removeView(view);
}
}