Search in sources :

Example 1 with UndoBarController

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;
    }
}
Also used : UndoBarController(it.gmariotti.cardslib.library.view.listener.UndoBarController) Activity(android.app.Activity) View(android.view.View) CardView(it.gmariotti.cardslib.library.view.CardView) AbsListView(android.widget.AbsListView) CardListView(it.gmariotti.cardslib.library.view.CardListView) ListView(android.widget.ListView) UndoCard(it.gmariotti.cardslib.library.view.listener.UndoCard)

Aggregations

Activity (android.app.Activity)1 View (android.view.View)1 AbsListView (android.widget.AbsListView)1 ListView (android.widget.ListView)1 CardListView (it.gmariotti.cardslib.library.view.CardListView)1 CardView (it.gmariotti.cardslib.library.view.CardView)1 UndoBarController (it.gmariotti.cardslib.library.view.listener.UndoBarController)1 UndoCard (it.gmariotti.cardslib.library.view.listener.UndoCard)1