()
| 2107 | |
| 2108 | /// {@inheritDoc} |
| 2109 | @Override |
| 2110 | public boolean animate() { |
| 2111 | // parent is performing the animation we shouldn't do anything in this case |
| 2112 | // this is the scrolling animation which we don't want to interfear with |
| 2113 | boolean parentFinished = super.animate(); |
| 2114 | if ((animationPosition != 0) && listMotion != null && !isDragActivated()) { |
| 2115 | if (animationPosition < 0) { |
| 2116 | animationPosition = Math.min(listMotion.getValue() - destination, 0); |
| 2117 | } else { |
| 2118 | animationPosition = Math.max(destination - listMotion.getValue(), 0); |
| 2119 | } |
| 2120 | if (animationPosition == 0) { |
| 2121 | listMotion = null; |
| 2122 | deregisterAnimatedInternal(); |
| 2123 | } |
| 2124 | return true; |
| 2125 | } |
| 2126 | if (fixedDraggedMotion != null) { |
| 2127 | int val = -fixedDraggedMotion.getValue(); |
| 2128 | fixedDraggedAnimationPosition = fixedDraggedAnimationPosition - (fixedDraggedPosition - val); |
| 2129 | fixedDraggedPosition = val; |
| 2130 | Dimension size = getElementSize(false, true); |
| 2131 | int s; |
| 2132 | if (orientation == VERTICAL) { |
| 2133 | s = size.getHeight(); |
| 2134 | } else { |
| 2135 | s = size.getWidth(); |
| 2136 | } |
| 2137 | |
| 2138 | if (fixedDraggedMotion.isFinished()) { |
| 2139 | deregisterAnimatedInternal(); |
| 2140 | //if after dragging the list is in the middle check which item |
| 2141 | //is the closest and animate to it. |
| 2142 | if (fixedDraggedAnimationPosition <= -s / 2) { |
| 2143 | fixedDraggedSelection++; |
| 2144 | if (fixedDraggedSelection >= model.getSize()) { |
| 2145 | fixedDraggedSelection = 0; |
| 2146 | } |
| 2147 | } else if (fixedDraggedAnimationPosition >= s / 2) { |
| 2148 | fixedDraggedSelection--; |
| 2149 | if (fixedDraggedSelection < 0) { |
| 2150 | fixedDraggedSelection = model.getSize() - 1; |
| 2151 | } |
| 2152 | } |
| 2153 | |
| 2154 | if (fixedDraggedAnimationPosition != 0) { |
| 2155 | if (fixedDraggedAnimationPosition < 0) { |
| 2156 | if (fixedDraggedAnimationPosition < -s / 2) { |
| 2157 | destination = s + fixedDraggedAnimationPosition; |
| 2158 | animationPosition = destination; |
| 2159 | } else { |
| 2160 | destination = -fixedDraggedAnimationPosition; |
| 2161 | animationPosition = fixedDraggedAnimationPosition; |
| 2162 | } |
| 2163 | |
| 2164 | } else { |
| 2165 | if (fixedDraggedAnimationPosition > s / 2) { |
| 2166 | destination = (s - fixedDraggedAnimationPosition); |
no test coverage detected