public abstract class ItemTouchExpandCallback extends Object
ItemTouchExpand object.
You can use this class to customize the behavior of the ItemTouchExpand object, for example, dragging or
swiping. A callback is invoked when the customized behavior is executed.
| 限定符和类型 | 类 | 说明 |
|---|---|---|
protected static class |
ItemTouchExpandCallback.ItemTouchExpandCallbackCleaner |
Implements the release of the
ItemTouchExpandCallback object. |
| 构造器 | 说明 |
|---|---|
ItemTouchExpandCallback(int dragDirs,
int swipeDirs) |
A constructor used to create a
ItemTouchExpandCallback instance. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
boolean |
canPutOnTop(ListComponent listComponent,
ComponentOwner current,
ComponentOwner target) |
Checks whether a component can be dragged to the target
ComponentOwner. |
long |
getAnimationTimePeriod(ListComponent listContainer,
int animationType,
float xCoordinateOffset,
float yCoordinateOffset) |
Obtains the duration of an animation.
|
int |
getAssumedDragDirections(ListComponent listContainer,
ComponentOwner componentOwner) |
Obtains the default drag directions of a component.
|
int |
getAssumedSwipeDirections(ListComponent listContainer,
ComponentOwner componentOwner) |
Obtains the default swipe directions of a component.
|
boolean |
getComponentSwipeAllowed() |
Checks whether this
ItemTouchExpand instance should start swiping when a component swipes. |
boolean |
getLongPressDragAllowed() |
Checks whether this
ItemTouchExpand instance should start dragging for a component that is being long
pressed. |
int |
getMarginOfOverlapRegion() |
Obtains the margin, which is used to calculate the overlapped area that can trigger the exchange between the
dragged component and the target component.
|
float |
getMoveLimit(ComponentOwner componentOwner) |
Obtains the threshold for triggering dragging for a component.
|
long |
getNativePtr() |
Obtains the native object.
|
float |
getSwipeLimit(ComponentOwner componentOwner) |
Obtains the threshold for triggering swiping for a component.
|
abstract boolean |
onMove(ListComponent listContainer,
ComponentOwner componentOwner,
ComponentOwner target) |
Called when a component is being dragged from a position to another in the provider.
|
void |
onSelectedItemUpdated(ComponentOwner componentOwner,
int actionState) |
Called when the component being swiped or dragging is updated.
|
abstract void |
onSwipeDetected(ComponentOwner componentOwner,
int direction) |
Called when a component is swiped.
|
ComponentOwner |
selectDropObjective(ComponentOwner selected,
List<ComponentOwner> dropTargets,
int curX,
int curY) |
Chooses a component among a list of
ComponentOwners that is closest to the one specified by
selected and exchanges their positions. |
void |
setAssumedDragDirections(int assumedDragDirections) |
Updates the default drag directions.
|
void |
setAssumedSwipeDirections(int assumedSwipeDirections) |
Updates the default swipe directions.
|
void |
setItemComponentSwipeAllowed(boolean componentSwipeEnabled) |
Sets whether this
ItemTouchExpand instance should start swiping when a component swipes. |
void |
setLongPressDragAllowed(boolean longPressDragEnabled) |
Sets whether this
ItemTouchExpand instance should start dragging for a component that is being long
pressed. |
void |
setMarginOfOverlapRegion(int marginOfBoundingBox) |
Sets the margin around the boundaries of the dragged component.
|
void |
setMoveLimit(ComponentOwner componentOwner,
float moveLimit) |
Sets the threshold for triggering dragging for a component.
|
void |
setSwipeLimit(ComponentOwner componentOwner,
float swipeLimit) |
Sets the threshold for trigger swiping for a component.
|
public ItemTouchExpandCallback(int dragDirs,
int swipeDirs)
ItemTouchExpandCallback instance.dragDirs - Indicates the drag directions, which must be a combination of
ItemTouchExpand#LEFT, ItemTouchExpand#RIGHT,
ItemTouchExpand#START, ItemTouchExpand#END, ItemTouchExpand#UP
and ItemTouchExpand#DOWN.swipeDirs - Indicates the swipe directions, which must be a combination of ItemTouchExpand#LEFT,
ItemTouchExpand#RIGHT, ItemTouchExpand#START, ItemTouchExpand#END,
ItemTouchExpand#UP, and ItemTouchExpand#DOWN.public long getNativePtr()
public abstract boolean onMove(ListComponent listContainer, ComponentOwner componentOwner, ComponentOwner target)
listContainer - Indicates the ListComponent bound to the ItemTouchExpand instance.componentOwner - Indicates the current ComponentOwner of the component that is being dragged.target - Indicates the new ComponentOwner of the component.true if the component is moved to the new position; returns false otherwise.public abstract void onSwipeDetected(ComponentOwner componentOwner, int direction)
componentOwner - Indicates the ComponentOwner of the component that is swiped.direction - Indicates the swipe direction, which can be ItemTouchExpand#UP,
ItemTouchExpand#DOWN, ItemTouchExpand#LEFT, or ItemTouchExpand#RIGHT.public void setLongPressDragAllowed(boolean longPressDragEnabled)
ItemTouchExpand instance should start dragging for a component that is being long
pressed.longPressDragEnabled - Specifies whether to start dragging for a component that is being long pressed. The
value true means to start dragging in such a case, and false means the opposite. The
default value is true.public boolean getLongPressDragAllowed()
ItemTouchExpand instance should start dragging for a component that is being long
pressed.true if the ItemTouchExpand instance should start dragging in such a case;
returns false otherwise.public void setItemComponentSwipeAllowed(boolean componentSwipeEnabled)
ItemTouchExpand instance should start swiping when a component swipes.componentSwipeEnabled - Specifies whether to start swiping when a component swipes. The value true
means to start swiping in such a case, and false means the opposite.public boolean getComponentSwipeAllowed()
ItemTouchExpand instance should start swiping when a component swipes.true if the ItemTouchExpand instance should start swiping when a component
swipes; returns false otherwise.public boolean canPutOnTop(ListComponent listComponent, ComponentOwner current, ComponentOwner target)
ComponentOwner.listContainer - Indicates the ListComponent bound to the ItemTouchExpand instance.componentOwner - Indicates the ComponentOwner of the component that is being dragged.target - Indicates the target ComponentOwner.true if the component can be dragged to the target ComponentOwner; returns
false otherwise.public void setSwipeLimit(ComponentOwner componentOwner, float swipeLimit)
componentOwner - Indicates the ComponentOwner of the component to swipe.swipeLimit - Indicates the threshold to set.public float getSwipeLimit(ComponentOwner componentOwner)
componentOwner - Indicates the ComponentOwner of the component that is being swiped.0 if componentOwner is null.public void setMoveLimit(ComponentOwner componentOwner, float moveLimit)
componentOwner - Indicates the ComponentOwner of the component to drag.moveLimit - Indicates the threshold to set.public float getMoveLimit(ComponentOwner componentOwner)
componentOwner - Indicates the ComponentOwner of the component that is being dragged.0 if componentOwner is null.public ComponentOwner selectDropObjective(ComponentOwner selected, List<ComponentOwner> dropTargets, int curX, int curY)
ComponentOwners that is closest to the one specified by
selected and exchanges their positions.selected - Indicates the ComponentOwner of the component that is being dragged.dropTargets - Indicates the list of ComponentOwners from which a component will be chosen as the
candidate.curX - Indicates the distance to be dragged in the horizontal direction.curY - Indicates the distance to be dragged in the vertical direction.ComponentOwner of the chosen component; returns null otherwise.public void onSelectedItemUpdated(ComponentOwner componentOwner, int actionState)
componentOwner - Indicates the ComponentOwner of the component that is being swiped or dragged.actionState - Indicates the action state of the ItemTouchExpand instance, which can be
ItemTouchExpand#ITEM_TOUCH_IDLE_STATE, ItemTouchExpand#ITEM_TOUCH_SWIPE_STATE, or
ItemTouchExpand#ITEM_TOUCH_DRAG_STATE.public void setAssumedSwipeDirections(int assumedSwipeDirections)
assumedSwipeDirections - Indicates the new default directions.public void setAssumedDragDirections(int assumedDragDirections)
assumedDragDirections - Indicates the new default drag directions.public int getAssumedSwipeDirections(ListComponent listContainer, ComponentOwner componentOwner)
listContainer - Indicates the ListComponent bound to the ItemTouchExpand instance.componentOwner - Indicates the ComponentOwner of the component to swipe.0 if componentOwner is null.public int getAssumedDragDirections(ListComponent listContainer, ComponentOwner componentOwner)
listContainer - Indicates the ListComponent bound to the ItemTouchExpand instance.componentOwner - Indicates the ComponentOwner of the component to drag.0 if componentOwner is null.public void setMarginOfOverlapRegion(int marginOfBoundingBox)
marginOfBoundingBox - Indicates the margin to set.public int getMarginOfOverlapRegion()
0 if an exception occurs.public long getAnimationTimePeriod(ListComponent listContainer, int animationType, float xCoordinateOffset, float yCoordinateOffset)
This method is called by the ItemTouchCallback instance when
the operation on a component is complete.
listComponent - Indicates the ListComponent bound to the ItemTouchExpand instanceanimationType - Indicates the animation type, which can be ItemTouchExpand#DRAG_ANIMATION_TYPE,
ItemTouchExpand#SWIPE_CANCEL_ANIMATION_TYPE, or
ItemTouchExpand#SWIPE_SUCCESS_ANIMATION_TYPE.xCoordinateOffset - Indicates the distance that the animation will move in the horizontal direction.yCoordinateOffset - Indicates the distance that the animation will move in the vertical direction.0 if an exception occurs.