本文整理汇总了Java中com.facebook.rebound.Spring.setAtRest方法的典型用法代码示例。如果您正苦于以下问题:Java Spring.setAtRest方法的具体用法?Java Spring.setAtRest怎么用?Java Spring.setAtRest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.rebound.Spring
的用法示例。
在下文中一共展示了Spring.setAtRest方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
}