public class UndoHelper
extends Snackbar.Callback
| Modifier and Type | Class and Description |
|---|---|
static interface |
UndoHelper.Action
Annotation interface for Undo actions.
|
static interface |
UndoHelper.OnActionListener |
| Modifier and Type | Field and Description |
|---|---|
static int |
UNDO_TIMEOUT
Default undo timeout of 5''.
|
| Constructor and Description |
|---|
UndoHelper(FlexibleAdapter adapter,
UndoHelper.OnActionListener undoListener)
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
onDeleteConfirmed(int event)
Note: This method is also invoked by
FlexibleAdapter#filterItems(List)
before applying the filter. |
void |
onDismissed(Snackbar snackbar,
int event) |
void |
onShown(Snackbar snackbar) |
Snackbar |
start(java.util.List<java.lang.Integer> positions,
android.view.View mainView,
java.lang.CharSequence message,
java.lang.CharSequence actionText,
int duration)
Performs the action on the specified positions and displays a SnackBar to Undo
the operation.
|
Snackbar |
start(java.util.List<java.lang.Integer> positions,
android.view.View mainView,
int messageStringResId,
int actionStringResId,
int duration)
As
start(List, View, CharSequence, CharSequence, int) but with String
resources instead of CharSequence. |
UndoHelper |
withAction(int action)
By default
UndoHelper.Action.REMOVE is performed. |
UndoHelper |
withActionTextColor(int color)
Sets the text color of the action.
|
UndoHelper |
withConsecutive(boolean consecutive)
Allows to commit previous action before next consecutive Undo request.
|
UndoHelper |
withPayload(java.lang.Object payload)
Sets the payload to inform other linked items about the change in action.
|
public static final int UNDO_TIMEOUT
public UndoHelper(FlexibleAdapter adapter,
UndoHelper.OnActionListener undoListener)
By calling this constructor, FlexibleAdapter#setPermanentDelete(boolean)
is set false automatically.
adapter - the instance of FlexibleAdapterundoListener - the callback for the Undo and Delete confirmationpublic UndoHelper withPayload(java.lang.Object payload)
payload - any non-null user object to notify the parent (the payload will be
therefore passed to the bind method of the parent ViewHolder),
pass null to not notify the parentpublic UndoHelper withAction(int action)
UndoHelper.Action.REMOVE is performed.action - the action, one of UndoHelper.Action.REMOVE, UndoHelper.Action.UPDATEpublic UndoHelper withActionTextColor(int color)
color - the color for the action buttonpublic UndoHelper withConsecutive(boolean consecutive)
Default value is false (accumulate items).
consecutive - true to commit deletion at each Undo request to undo last action,
false to accumulate the deleted items and Undo all in one shot.public Snackbar start(java.util.List<java.lang.Integer> positions,
android.view.View mainView,
int messageStringResId,
int actionStringResId,
int duration)
start(List, View, CharSequence, CharSequence, int) but with String
resources instead of CharSequence.public Snackbar start(java.util.List<java.lang.Integer> positions,
android.view.View mainView,
java.lang.CharSequence message,
java.lang.CharSequence actionText,
int duration)
withAction(int) method.
By default the DELETE action will be performed.
positions - the position to delete or updatemainView - the view to find a parent frommessage - the text to show. Can be formatted textactionText - the action text to displayduration - How long to display the message. Either Snackbar#LENGTH_SHORT or
Snackbar#LENGTH_LONG or any custom Integer.start(List, View, int, int, int)public void onDeleteConfirmed(int event)
Note: This method is also invoked by FlexibleAdapter#filterItems(List)
before applying the filter.
public void onDismissed(Snackbar snackbar,
int event)
public void onShown(Snackbar snackbar)