本文整理匯總了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);
}
}
}