@@ -144,7 +144,7 @@ public KeylineState getShiftedState(
144144 * been shifted exactly according to the scroll offset.
145145 * @return a {@link KeylineState} that has been shifted according on the scroll offset.
146146 */
147- KeylineState getShiftedState (
147+ KeylineState getShiftedState (
148148 float scrollOffset ,
149149 float minScrollOffset ,
150150 float maxScrollOffset ,
@@ -154,34 +154,34 @@ KeylineState getShiftedState(
154154 List <KeylineState > steps ;
155155 float [] interpolationPoints ;
156156 float interpolation ;
157- if (scrollOffset < startShiftOffset ) {
158- interpolation =
159- AnimationUtils .lerp (
160- /* outputMin= */ 1F ,
161- /* outputMax= */ 0F ,
162- /* inputMin: */ minScrollOffset ,
163- /* inputMax= */ startShiftOffset ,
164- /* value= */ scrollOffset );
165- steps = startStateSteps ;
166- interpolationPoints = startStateStepsInterpolationPoints ;
167- } else if (scrollOffset > endShiftOffset ) {
168- interpolation =
169- AnimationUtils .lerp (
170- /* outputMin= */ 0F ,
171- /* outputMax= */ 1F ,
172- /* inputMin= */ endShiftOffset ,
173- /* inputMax= */ maxScrollOffset ,
174- /* value= */ scrollOffset );
175- steps = endStateSteps ;
176- interpolationPoints = endStateStepsInterpolationPoints ;
177- } else {
178- return defaultState ;
179- }
180-
181- if (roundToNearestStep ) {
182- return closestStateStepFromInterpolation (steps , interpolation , interpolationPoints );
183- }
184- return lerp (steps , interpolation , interpolationPoints );
157+ if (scrollOffset < startShiftOffset ) {
158+ interpolation =
159+ AnimationUtils .lerp (
160+ /* outputMin= */ 1F ,
161+ /* outputMax= */ 0F ,
162+ /* inputMin: */ minScrollOffset ,
163+ /* inputMax= */ startShiftOffset ,
164+ /* value= */ scrollOffset );
165+ steps = startStateSteps ;
166+ interpolationPoints = startStateStepsInterpolationPoints ;
167+ } else if (scrollOffset > endShiftOffset ) {
168+ interpolation =
169+ AnimationUtils .lerp (
170+ /* outputMin= */ 0F ,
171+ /* outputMax= */ 1F ,
172+ /* inputMin= */ endShiftOffset ,
173+ /* inputMax= */ maxScrollOffset ,
174+ /* value= */ scrollOffset );
175+ steps = endStateSteps ;
176+ interpolationPoints = endStateStepsInterpolationPoints ;
177+ } else {
178+ return defaultState ;
179+ }
180+
181+ if (roundToNearestStep ) {
182+ return closestStateStepFromInterpolation (steps , interpolation , interpolationPoints );
183+ }
184+ return lerp (steps , interpolation , interpolationPoints );
185185 }
186186
187187 /**
@@ -213,12 +213,12 @@ private static KeylineState lerp(
213213 * @param stateSteps The steps in which to determine the 2 state steps we are in between.
214214 * @param interpolation The interpolation of the state steps we are at.
215215 * @param stateStepsInterpolationPoints The state step interpolation points; each interpolation
216- * point corresponds to at which interpolation we are at the corresponding state step.
216+ * point corresponds to at which interpolation we are at the corresponding state step.
217217 * @return an array of the form [progress, fromIndex, toIndex] where progress represents the
218- * progress in between the state steps at fromIndex and toIndex.
218+ * progress in between the state steps at fromIndex and toIndex.
219219 */
220- private static float [] getStateStepsRange (List < KeylineState > stateSteps ,
221- float interpolation , float [] stateStepsInterpolationPoints ) {
220+ private static float [] getStateStepsRange (
221+ List < KeylineState > stateSteps , float interpolation , float [] stateStepsInterpolationPoints ) {
222222 int numberOfSteps = stateSteps .size ();
223223 // Find the step that contains `interpolation` and remap the the surrounding interpolation
224224 // points lower and upper bounds to its own 0-1 value.
@@ -365,8 +365,7 @@ private static List<KeylineState> getStateStepsStart(
365365 // If the first focal item is already at the left of the container or there are no in bounds
366366 // keylines, return a list of steps that only includes the default state (there is nowhere to
367367 // shift).
368- if (isFirstFocalItemAtLeftOfContainer (defaultState )
369- || firstNonAnchorKeylineIndex == NO_INDEX ) {
368+ if (isFirstFocalItemAtLeftOfContainer (defaultState ) || firstNonAnchorKeylineIndex == NO_INDEX ) {
370369 return steps ;
371370 }
372371
@@ -438,8 +437,7 @@ private static List<KeylineState> getStateStepsStart(
438437 * last state will be the right state or the state that has the focal range at the right of the
439438 * carousel.
440439 */
441- private static List <KeylineState > getStateStepsEnd (
442- Carousel carousel , KeylineState defaultState ) {
440+ private static List <KeylineState > getStateStepsEnd (Carousel carousel , KeylineState defaultState ) {
443441 List <KeylineState > steps = new ArrayList <>();
444442 steps .add (defaultState );
445443 int lastNonAnchorKeylineIndex = findLastNonAnchorKeylineIndex (defaultState );
@@ -643,9 +641,9 @@ Map<Integer, KeylineState> getKeylineStateForPositionMap(
643641 keylineStates .put (
644642 position ,
645643 startStateSteps .get (MathUtils .clamp (startStepsIndex , 0 , startStateSteps .size () - 1 )));
646- startStepsIndex ++;
647- }
644+ startStepsIndex ++;
648645 }
646+ }
649647 return keylineStates ;
650648 }
651649}
0 commit comments