public class SwipeHelper extends Object implements Gefingerpoken
Modifier and Type | Class and Description |
---|---|
static interface |
SwipeHelper.Callback |
static interface |
SwipeHelper.LongPressListener
Equivalent to View.OnLongClickListener with coordinates
|
Constructor and Description |
---|
SwipeHelper(int swipeDirection,
SwipeHelper.Callback callback,
Context context) |
Modifier and Type | Method and Description |
---|---|
protected ObjectAnimator |
createTranslationAnimation(View v,
float newPos) |
void |
dismissChild(View view,
float velocity,
boolean useAccelerateInterpolator) |
void |
dismissChild(View animView,
float velocity,
Runnable endAction,
long delay,
boolean useAccelerateInterpolator,
long fixedDuration,
boolean isDismissAll) |
protected float |
getEscapeVelocity() |
protected long |
getMaxEscapeAnimDuration() |
protected float |
getSize(View v) |
protected float |
getTranslation(View v) |
protected float |
getUnscaledEscapeVelocity() |
protected Animator |
getViewTranslationAnimator(View v,
float target,
ValueAnimator.AnimatorUpdateListener listener) |
protected boolean |
handleUpEvent(MotionEvent ev,
View animView,
float velocity,
float translation) |
static void |
invalidateGlobalRegion(View view) |
static void |
invalidateGlobalRegion(View view,
RectF childBounds) |
protected boolean |
isDismissGesture(MotionEvent ev) |
void |
onDownUpdate(View currView)
Called when there's a down event.
|
boolean |
onInterceptTouchEvent(MotionEvent ev) |
protected void |
onMoveUpdate(View view,
float totalTranslation,
float delta)
Called on a move event.
|
boolean |
onTouchEvent(MotionEvent ev) |
void |
onTranslationUpdate(View animView,
float value,
boolean canBeDismissed)
Called in
ValueAnimator.AnimatorUpdateListener.onAnimationUpdate(ValueAnimator) when the current
view is being animated to dismiss or snap. |
protected void |
prepareDismissAnimation(View view,
Animator anim)
Called to update the dismiss animation.
|
protected void |
prepareSnapBackAnimation(View view,
Animator anim)
Called to update the snap back animation.
|
void |
removeLongPressCallback() |
void |
setDensityScale(float densityScale) |
void |
setDisableHardwareLayers(boolean disableHwLayers) |
void |
setLongPressListener(SwipeHelper.LongPressListener listener) |
void |
setMaxSwipeProgress(float maxSwipeProgress) |
void |
setMinSwipeProgress(float minSwipeProgress) |
void |
setPagingTouchSlop(float pagingTouchSlop) |
protected void |
setTranslation(View v,
float translate) |
void |
snapChild(View animView,
float targetLeft,
float velocity) |
void |
snapChildIfNeeded(View view,
boolean animate,
float targetLeft)
Called when a view is updated to be non-dismissable, if the view was being dismissed before
the update this will handle snapping it back into place.
|
protected boolean |
swipedFarEnough() |
protected boolean |
swipedFastEnough() |
public static final int X
public static final int Y
public SwipeHelper(int swipeDirection, SwipeHelper.Callback callback, Context context)
public void setLongPressListener(SwipeHelper.LongPressListener listener)
public void setDensityScale(float densityScale)
public void setPagingTouchSlop(float pagingTouchSlop)
public void setDisableHardwareLayers(boolean disableHwLayers)
protected float getTranslation(View v)
protected ObjectAnimator createTranslationAnimation(View v, float newPos)
protected Animator getViewTranslationAnimator(View v, float target, ValueAnimator.AnimatorUpdateListener listener)
protected void setTranslation(View v, float translate)
protected float getSize(View v)
public void setMinSwipeProgress(float minSwipeProgress)
public void setMaxSwipeProgress(float maxSwipeProgress)
public static void invalidateGlobalRegion(View view)
public void removeLongPressCallback()
public boolean onInterceptTouchEvent(MotionEvent ev)
onInterceptTouchEvent
in interface Gefingerpoken
public void dismissChild(View view, float velocity, boolean useAccelerateInterpolator)
view
- The view to be dismissedvelocity
- The desired pixels/second speed at which the view should moveuseAccelerateInterpolator
- Should an accelerating Interpolator be usedpublic void dismissChild(View animView, float velocity, Runnable endAction, long delay, boolean useAccelerateInterpolator, long fixedDuration, boolean isDismissAll)
view
- The view to be dismissedvelocity
- The desired pixels/second speed at which the view should moveendAction
- The action to perform at the enddelay
- The delay after which we should startuseAccelerateInterpolator
- Should an accelerating Interpolator be usedfixedDuration
- If not 0, this exact duration will be takenprotected void prepareDismissAnimation(View view, Animator anim)
public void snapChild(View animView, float targetLeft, float velocity)
protected void prepareSnapBackAnimation(View view, Animator anim)
public void onDownUpdate(View currView)
protected void onMoveUpdate(View view, float totalTranslation, float delta)
public void onTranslationUpdate(View animView, float value, boolean canBeDismissed)
ValueAnimator.AnimatorUpdateListener.onAnimationUpdate(ValueAnimator)
when the current
view is being animated to dismiss or snap.public void snapChildIfNeeded(View view, boolean animate, float targetLeft)
view
- the view to snap if necessary.animate
- whether to animate the snap or not.targetLeft
- the target to snap to.public boolean onTouchEvent(MotionEvent ev)
onTouchEvent
in interface Gefingerpoken
protected float getEscapeVelocity()
protected float getUnscaledEscapeVelocity()
protected long getMaxEscapeAnimDuration()
protected boolean swipedFarEnough()
protected boolean isDismissGesture(MotionEvent ev)
protected boolean swipedFastEnough()
protected boolean handleUpEvent(MotionEvent ev, View animView, float velocity, float translation)