use of it.gmariotti.cardslib.library.view.listener.UndoBarController in project cardslib by gabrielemariotti.
the class CardArrayAdapter method setEnableUndo.
/**
* Enables an undo message after a swipe action
*
* @param enableUndo <code>true</code> to enable an undo message
*/
public void setEnableUndo(boolean enableUndo) {
mEnableUndo = enableUndo;
if (enableUndo) {
mInternalObjects = new HashMap<String, Card>();
for (int i = 0; i < getCount(); i++) {
Card card = getItem(i);
mInternalObjects.put(card.getId(), card);
}
//Create a UndoController
if (mUndoBarController == null) {
if (mUndoBarUIElements == null)
mUndoBarUIElements = new UndoBarController.DefaultUndoBarUIElements();
if (mContext != null && mContext instanceof Activity) {
View undobar = ((Activity) mContext).findViewById(mUndoBarUIElements.getUndoBarId());
if (undobar != null) {
mUndoBarController = new UndoBarController(undobar, this, mUndoBarUIElements);
}
} else {
Log.e(TAG, "Undo Action requires a valid Activity context");
throw new IllegalArgumentException("Undo Action requires a valid Activity context");
}
}
} else {
mUndoBarController = null;
}
}
Aggregations