net.simonvt.menudrawer
Class FloatScroller

java.lang.Object
  extended by net.simonvt.menudrawer.FloatScroller

public class FloatScroller
extends Object

This class encapsulates scrolling. The duration of the scroll can be passed in the constructor and specifies the maximum time that the scrolling animation should take. Past this time, the scrolling is automatically moved to its final stage and computeScrollOffset() will always return false to indicate that scrolling is over.


Constructor Summary
FloatScroller(android.view.animation.Interpolator interpolator)
          Create a Scroller with the specified interpolator.
 
Method Summary
 void abortAnimation()
          Stops the animation.
 boolean computeScrollOffset()
           
 void extendDuration(int extend)
          Extend the scroll animation.
 void forceFinished(boolean finished)
          Force the finished field to a particular value.
 float getCurr()
          Returns the current offset in the scroll.
 int getDuration()
          Returns how long the scroll event will take, in milliseconds.
 float getFinal()
          Returns where the scroll will end.
 float getStart()
          Returns the start offset in the scroll.
 boolean isFinished()
          Returns whether the scroller has finished scrolling.
 void setFinal(float newVal)
           
 void startScroll(float start, float delta, int duration)
           
 int timePassed()
          Returns the time elapsed since the beginning of the scrolling.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FloatScroller

public FloatScroller(android.view.animation.Interpolator interpolator)
Create a Scroller with the specified interpolator. If the interpolator is null, the default (viscous) interpolator will be used. Specify whether or not to support progressive "flywheel" behavior in flinging.

Method Detail

isFinished

public final boolean isFinished()
Returns whether the scroller has finished scrolling.

Returns:
True if the scroller has finished scrolling, false otherwise.

forceFinished

public final void forceFinished(boolean finished)
Force the finished field to a particular value.

Parameters:
finished - The new finished value.

getDuration

public final int getDuration()
Returns how long the scroll event will take, in milliseconds.

Returns:
The duration of the scroll in milliseconds.

getCurr

public final float getCurr()
Returns the current offset in the scroll.

Returns:
The new offset as an absolute distance from the origin.

getStart

public final float getStart()
Returns the start offset in the scroll.

Returns:
The start offset as an absolute distance from the origin.

getFinal

public final float getFinal()
Returns where the scroll will end. Valid only for "fling" scrolls.

Returns:
The final offset as an absolute distance from the origin.

computeScrollOffset

public boolean computeScrollOffset()

startScroll

public void startScroll(float start,
                        float delta,
                        int duration)

abortAnimation

public void abortAnimation()
Stops the animation. Contrary to forceFinished(boolean), aborting the animating cause the scroller to move to the final x and y position

See Also:
forceFinished(boolean)

extendDuration

public void extendDuration(int extend)
Extend the scroll animation. This allows a running animation to scroll further and longer, when used with setFinal(float).

Parameters:
extend - Additional time to scroll in milliseconds.
See Also:
setFinal(float)

timePassed

public int timePassed()
Returns the time elapsed since the beginning of the scrolling.

Returns:
The elapsed time in milliseconds.

setFinal

public void setFinal(float newVal)


Copyright © 2012-2013. All Rights Reserved.