當前位置: 首頁>>代碼示例>>Java>>正文


Java Spring.setAtRest方法代碼示例

本文整理匯總了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);
        }
    }
}
 
開發者ID:flipkart-incubator,項目名稱:springy-heads,代碼行數:65,代碼來源:MaximizedArrangement.java


注:本文中的com.facebook.rebound.Spring.setAtRest方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。