public class

ObjectCellSwipeControl

extends ItemTouchHelper.SimpleCallback
java.lang.Object
   ↳ androidx.recyclerview.widget.ItemTouchHelper.Callback
     ↳ androidx.recyclerview.widget.ItemTouchHelper.SimpleCallback
       ↳ com.sap.cloud.mobile.fiori.object.ObjectCellSwipeControl

Summary

Nested Classes
interface ObjectCellSwipeControl.ObjectCellSwipeControlListener This interface is deprecated. This function is deprecated. Use ObjectCellSwipeListener instead.  
interface ObjectCellSwipeControl.ObjectCellSwipeListener The listener interface which the user should implement in an activity for actions corresponding to swiping gestures. 
[Expand]
Inherited Constants
From class androidx.recyclerview.widget.ItemTouchHelper.Callback
Fields
protected ColorDrawable mLeftBackground
protected Drawable mLeftIcon
protected HashMap<StringPair<ColorDrawableDrawable>> mLeftMappings
protected ColorDrawable mRightBackground
protected Drawable mRightIcon
protected HashMap<StringPair<ColorDrawableDrawable>> mRightMappings
protected float mSwipeThreshold
protected float mSwipeToLeftRatio
protected float mSwipeToRightRatio
Public Constructors
ObjectCellSwipeControl(Context context, ObjectCellSwipeControl.ObjectCellSwipeListener listener)
ObjectCellSwipeControl(Context context, ObjectCellSwipeControl.ObjectCellSwipeControlListener listener)
This constructor is deprecated. This function is deprecated. Use {ObjectCellSwipeControl(Context, ObjectCellSwipeListener) instead.
Public Methods
void addLeftMapping(String key, int color, Drawable icon)
void addRightMapping(String key, int color, Drawable icon)
float getSwipeThreshold(RecyclerView.ViewHolder viewHolder)
boolean isLongPressDragEnabled()
void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive)
boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target)
void onSwiped(RecyclerView.ViewHolder viewHolder, int direction)
Call back function for Swipe gesture, which calls on the listener's methods which user should implement in his/her own Activity.
void removeLeftMapping(String key)
void removeRightMapping(String key)
void setBackground(int resId)
This method is deprecated. This function is deprecated. Use {setLeftBackgroundColor(int) and {setRightBackgroundColor(int) instead.
void setBackgroundColor(int myColor)
This method is deprecated. This function is deprecated. Use {setLeftBackgroundColor(int) and {setRightBackgroundColor(int) instead.
void setIcon(Drawable myIcon)
This method is deprecated. This function is deprecated. Use {setLeftIcon(int) and {setRightIcon(int) instead.
void setIcon(int resId)
This method is deprecated. This function is deprecated. Use {setLeftIcon(int) and {setRightIcon(int) instead.
void setLeftBackgroundColor(int myColor)
Set the background color when Object Cell is being swiped off the screen to the right.
void setLeftIcon(Drawable myIcon)
Set the icon displayed on the background when Object Cell is being swiped off the screen to the right.
void setLeftIcon(int resId)
Set the icon displayed on the background when Object Cell is being swiped off the screen to the right.
void setRightBackgroundColor(int myColor)
Set the background color when Object Cell is being swiped off the screen to the left.
void setRightIcon(int resId)
Set the icon displayed on the background when Object Cell is being swiped off the screen to the left.
void setRightIcon(Drawable myIcon)
Set the icon displayed on the background when Object Cell is being swiped off the screen to the left.
void setSwipeThreshold(float threshold)
The threshold determines when a movement is considered a swipe and the item snaps to position.
void setSwipeToLeftRatio(float ratio)
Sets the ratio dictating how much the item is moved upon a left swipe.
void setSwipeToRightRatio(float ratio)
Sets the ratio dictating how much the item is moved upon a right swipe.
[Expand]
Inherited Methods
From class androidx.recyclerview.widget.ItemTouchHelper.SimpleCallback
From class androidx.recyclerview.widget.ItemTouchHelper.Callback
From class java.lang.Object

Fields

protected ColorDrawable mLeftBackground

protected Drawable mLeftIcon

protected HashMap<StringPair<ColorDrawableDrawable>> mLeftMappings

protected ColorDrawable mRightBackground

protected Drawable mRightIcon

protected HashMap<StringPair<ColorDrawableDrawable>> mRightMappings

protected float mSwipeThreshold

protected float mSwipeToLeftRatio

protected float mSwipeToRightRatio

Public Constructors

public ObjectCellSwipeControl (Context context, ObjectCellSwipeControl.ObjectCellSwipeListener listener)

public ObjectCellSwipeControl (Context context, ObjectCellSwipeControl.ObjectCellSwipeControlListener listener)

This constructor is deprecated.
This function is deprecated. Use {ObjectCellSwipeControl(Context, ObjectCellSwipeListener) instead.

Public Methods

public void addLeftMapping (String key, int color, Drawable icon)

public void addRightMapping (String key, int color, Drawable icon)

public float getSwipeThreshold (RecyclerView.ViewHolder viewHolder)

public boolean isLongPressDragEnabled ()

public void onChildDraw (Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive)

public boolean onMove (RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target)

public void onSwiped (RecyclerView.ViewHolder viewHolder, int direction)

Call back function for Swipe gesture, which calls on the listener's methods which user should implement in his/her own Activity.

Parameters
viewHolder the view holder of the recycler view
direction the swiping direction: LEFT or RIGHT

public void removeLeftMapping (String key)

public void removeRightMapping (String key)

public void setBackground (int resId)

This method is deprecated.
This function is deprecated. Use {setLeftBackgroundColor(int) and {setRightBackgroundColor(int) instead.

Set the background color when Object Cell is being swiped off the screen.

Parameters
resId the resource ID for the color

public void setBackgroundColor (int myColor)

This method is deprecated.
This function is deprecated. Use {setLeftBackgroundColor(int) and {setRightBackgroundColor(int) instead.

Set the background color when Object Cell is being swiped off the screen.

Parameters
myColor a ColorDrawable for the background color

public void setIcon (Drawable myIcon)

This method is deprecated.
This function is deprecated. Use {setLeftIcon(int) and {setRightIcon(int) instead.

Set the icon displayed on the background when Object Cell is being swiped off the screen.

Parameters
myIcon a drawable icon.

public void setIcon (int resId)

This method is deprecated.
This function is deprecated. Use {setLeftIcon(int) and {setRightIcon(int) instead.

Set the icon displayed on the background when Object Cell is being swiped off the screen.

Parameters
resId the resource ID for icon drawable.

public void setLeftBackgroundColor (int myColor)

Set the background color when Object Cell is being swiped off the screen to the right.

Parameters
myColor a ColorDrawable for the background color

public void setLeftIcon (Drawable myIcon)

Set the icon displayed on the background when Object Cell is being swiped off the screen to the right.

Parameters
myIcon a drawable icon.

public void setLeftIcon (int resId)

Set the icon displayed on the background when Object Cell is being swiped off the screen to the right.

Parameters
resId the resource ID for icon drawable.

public void setRightBackgroundColor (int myColor)

Set the background color when Object Cell is being swiped off the screen to the left.

Parameters
myColor a ColorDrawable for the background color

public void setRightIcon (int resId)

Set the icon displayed on the background when Object Cell is being swiped off the screen to the left.

Parameters
resId the resource ID for icon drawable.

public void setRightIcon (Drawable myIcon)

Set the icon displayed on the background when Object Cell is being swiped off the screen to the left.

Parameters
myIcon a drawable icon.

public void setSwipeThreshold (float threshold)

The threshold determines when a movement is considered a swipe and the item snaps to position. onSwiped() is called when the swipe results in the item being moved out of its default position. These types of swipes could also be determined by the minimum escape velocity. The threshold is the point corresponding to the given ratio of the distance moved on a swipe. For example: If a full swipe moves the item 50% of its width, and the threshold is .4f, then the point that triggers a right swipe is at .5f * .4f = 20% of the item width. To swipe the item back into the default state, this same point must be crossed, so it is more difficult to swipe back in this case, especially since escape velocity is not considered.

public void setSwipeToLeftRatio (float ratio)

Sets the ratio dictating how much the item is moved upon a left swipe.

Parameters
ratio The ratio of the item width that the item will be moved upon a successful swipe to the left.

public void setSwipeToRightRatio (float ratio)

Sets the ratio dictating how much the item is moved upon a right swipe.

Parameters
ratio The ratio of the item width that the item will be moved upon a successful swipe to the right.