本文整理汇总了Java中com.facebook.rebound.Spring.setSpringConfig方法的典型用法代码示例。如果您正苦于以下问题:Java Spring.setSpringConfig方法的具体用法?Java Spring.setSpringConfig怎么用?Java Spring.setSpringConfig使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.rebound.Spring
的用法示例。
在下文中一共展示了Spring.setSpringConfig方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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 );
}
}
示例2: 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);
}
示例3: initializeSpring
import com.facebook.rebound.Spring; //导入方法依赖的package包/类
private static Spring initializeSpring(final View view, final int startTranslationX, final int startTranslationY, boolean overshoot)
{
view.setTranslationX(startTranslationX);
view.setTranslationY(startTranslationY);
view.setVisibility(View.VISIBLE);
// Create a system to run the physics loop for a set of springs.
SpringSystem springSystem = SpringSystem.create();
// Add a spring to the system.
Spring spring = springSystem.createSpring();
spring.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(80, 7));
spring.setOvershootClampingEnabled(!overshoot);
return spring;
}
示例4: onSpringUpdate
import com.facebook.rebound.Spring; //导入方法依赖的package包/类
@Override
public void onSpringUpdate(ChatHead activeChatHead, boolean isDragging, int maxWidth, int maxHeight, Spring spring, Spring activeHorizontalSpring, Spring activeVerticalSpring, int totalVelocity) {
/** Bounds Check **/
if (spring == activeHorizontalSpring && !isDragging) {
double xPosition = activeHorizontalSpring.getCurrentValue();
if (xPosition + manager.getConfig().getHeadWidth() > maxWidth && activeHorizontalSpring.getSpringConfig() != SpringConfigsHolder.NOT_DRAGGING && !activeHorizontalSpring.isOvershooting()) {
positionToOriginal(activeChatHead, activeHorizontalSpring, activeVerticalSpring);
}
if (xPosition < 0 && activeHorizontalSpring.getSpringConfig() != SpringConfigsHolder.NOT_DRAGGING && !activeHorizontalSpring.isOvershooting()) {
positionToOriginal(activeChatHead, activeHorizontalSpring, activeVerticalSpring);
}
} else if (spring == activeVerticalSpring && !isDragging) {
double yPosition = activeVerticalSpring.getCurrentValue();
if (yPosition + manager.getConfig().getHeadHeight() > maxHeight && activeHorizontalSpring.getSpringConfig() != SpringConfigsHolder.NOT_DRAGGING && !activeHorizontalSpring.isOvershooting()) {
positionToOriginal(activeChatHead, activeHorizontalSpring, activeVerticalSpring);
}
if (yPosition < 0 && activeHorizontalSpring.getSpringConfig() != SpringConfigsHolder.NOT_DRAGGING && !activeHorizontalSpring.isOvershooting()) {
positionToOriginal(activeChatHead, activeHorizontalSpring, activeVerticalSpring);
}
}
/** position it back **/
if (!isDragging && totalVelocity < MIN_VELOCITY_TO_POSITION_BACK && activeHorizontalSpring.getSpringConfig() == SpringConfigsHolder.DRAGGING) {
positionToOriginal(activeChatHead, activeHorizontalSpring, activeVerticalSpring);
}
if (activeChatHead == currentChatHead)
showOrHideView(activeChatHead);
if (!isDragging) {
/** Capturing check **/
int[] coords = manager.getChatHeadCoordsForCloseButton(activeChatHead);
double distanceCloseButtonFromHead = manager.getDistanceCloseButtonFromHead((float) activeHorizontalSpring.getCurrentValue() + manager.getConfig().getHeadWidth() / 2, (float) activeVerticalSpring.getCurrentValue() + manager.getConfig().getHeadHeight() / 2);
if (distanceCloseButtonFromHead < activeChatHead.CLOSE_ATTRACTION_THRESHOLD && activeHorizontalSpring.getSpringConfig() == SpringConfigsHolder.DRAGGING && activeVerticalSpring.getSpringConfig() == SpringConfigsHolder.DRAGGING && !activeChatHead.isSticky()) {
activeHorizontalSpring.setSpringConfig(SpringConfigsHolder.NOT_DRAGGING);
activeVerticalSpring.setSpringConfig(SpringConfigsHolder.NOT_DRAGGING);
activeChatHead.setState(ChatHead.State.CAPTURED);
}
if (activeChatHead.getState() == ChatHead.State.CAPTURED && activeHorizontalSpring.getSpringConfig() != SpringConfigsHolder.CAPTURING) {
activeHorizontalSpring.setAtRest();
activeVerticalSpring.setAtRest();
activeHorizontalSpring.setSpringConfig(SpringConfigsHolder.CAPTURING);
activeVerticalSpring.setSpringConfig(SpringConfigsHolder.CAPTURING);
activeHorizontalSpring.setEndValue(coords[0]);
activeVerticalSpring.setEndValue(coords[1]);
}
if (activeChatHead.getState() == ChatHead.State.CAPTURED && activeVerticalSpring.isAtRest()) {
manager.getCloseButton().disappear(false, true);
manager.captureChatHeads(activeChatHead);
}
if (!activeVerticalSpring.isAtRest() && !isTransitioning) {
manager.getCloseButton().appear();
} else {
manager.getCloseButton().disappear(true, true);
}
}
}