FileDocCategorySizeDatePackage
EdgeEffectCompat.javaAPI DocAndroid 5.1 API7755Thu Mar 12 22:22:56 GMT 2015android.support.v4.widget

EdgeEffectCompat

public class EdgeEffectCompat extends Object
Helper for accessing {@link android.widget.EdgeEffect} introduced after API level 4 in a backwards compatible fashion. This class is used to access {@link android.widget.EdgeEffect} on platform versions that support it. When running on older platforms it will result in no-ops. It should be used by views that wish to use the standard Android visual effects at the edges of scrolling containers.

Fields Summary
private Object
mEdgeEffect
private static final EdgeEffectImpl
IMPL
Constructors Summary
public EdgeEffectCompat(android.content.Context context)
Construct a new EdgeEffect themed using the given context.

Note: On platform versions that do not support EdgeEffect, all operations on the newly constructed object will be mocked/no-ops.

param
context Context to use for theming the effect

        mEdgeEffect = IMPL.newEdgeEffect(context);
    
Methods Summary
public booleandraw(android.graphics.Canvas canvas)
Draw into the provided canvas. Assumes that the canvas has been rotated accordingly and the size has been set. The effect will be drawn the full width of X=0 to X=width, beginning from Y=0 and extending to some factor < 1.f of height.

param
canvas Canvas to draw into
return
true if drawing should continue beyond this frame to continue the animation

        return IMPL.draw(mEdgeEffect, canvas);
    
public voidfinish()
Immediately finish the current animation. After this call {@link #isFinished()} will return true.

        IMPL.finish(mEdgeEffect);
    
public booleanisFinished()
Reports if this EdgeEffectCompat's animation is finished. If this method returns false after a call to {@link #draw(Canvas)} the host widget should schedule another drawing pass to continue the animation.

return
true if animation is finished, false if drawing should continue on the next frame.

        return IMPL.isFinished(mEdgeEffect);
    
public booleanonAbsorb(int velocity)
Call when the effect absorbs an impact at the given velocity. Used when a fling reaches the scroll boundary.

When using a {@link android.widget.Scroller} or {@link android.widget.OverScroller}, the method getCurrVelocity will provide a reasonable approximation to use here.

param
velocity Velocity at impact in pixels per second.
return
true if the host view should invalidate, false if it should not.

        return IMPL.onAbsorb(mEdgeEffect, velocity);
    
public booleanonPull(float deltaDistance)
A view should call this when content is pulled away from an edge by the user. This will update the state of the current visual effect and its associated animation. The host view should always {@link android.view.View#invalidate()} if this method returns true and draw the results accordingly.

param
deltaDistance Change in distance since the last call. Values may be 0 (no change) to 1.f (full length of the view) or negative values to express change back toward the edge reached to initiate the effect.
return
true if the host view should call invalidate, false if it should not.

        return IMPL.onPull(mEdgeEffect, deltaDistance);
    
public booleanonRelease()
Call when the object is released after being pulled. This will begin the "decay" phase of the effect. After calling this method the host view should {@link android.view.View#invalidate()} if this method returns true and thereby draw the results accordingly.

return
true if the host view should invalidate, false if it should not.

        return IMPL.onRelease(mEdgeEffect);
    
public voidsetSize(int width, int height)
Set the size of this edge effect in pixels.

param
width Effect width in pixels
param
height Effect height in pixels

        IMPL.setSize(mEdgeEffect, width, height);