Search in sources :

Example 1 with CardViewWrapper

use of it.gmariotti.cardslib.library.view.base.CardViewWrapper in project cardslib by gabrielemariotti.

the class CardGridArrayAdapter method getView.

// -------------------------------------------------------------
// Views
// -------------------------------------------------------------
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View view = convertView;
    CardViewWrapper mCardView;
    Card mCard;
    LayoutInflater mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    //Retrieve card from items
    mCard = (Card) getItem(position);
    if (mCard != null) {
        int layout = mRowLayoutId;
        boolean recycle = false;
        //Inflate layout
        if (view == null) {
            recycle = false;
            view = mInflater.inflate(layout, parent, false);
        } else {
            recycle = true;
        }
        //Setup card
        mCardView = (CardViewWrapper) view.findViewById(R.id.list_cardId);
        if (mCardView != null) {
            //It is important to set recycle value for inner layout elements
            mCardView.setForceReplaceInnerLayout(Card.equalsInnerLayout(mCardView.getCard(), mCard));
            //It is important to set recycle value for performance issue
            mCardView.setRecycle(recycle);
            //Save original swipeable value
            boolean origianlSwipeable = mCard.isSwipeable();
            //Set false to avoid swape card default action
            mCard.setSwipeable(false);
            mCardView.setCard(mCard);
            //mCard.setSwipeable(origianlSwipeable);
            if (origianlSwipeable)
                Log.d(TAG, "Swipe action not enabled in this type of view");
            //If card has an expandable button override animation
            if (mCard.getCardHeader() != null && mCard.getCardHeader().isButtonExpandVisible()) {
                //setupExpandCollapseListAnimation(mCardView);
                Log.d(TAG, "Expand action not enabled in this type of view");
            }
            //Setup swipeable animation
            setupSwipeableAnimation(mCard, mCardView);
            //setupMultiChoice
            setupMultichoice(view, mCard, mCardView, position);
        }
    }
    return view;
}
Also used : LayoutInflater(android.view.LayoutInflater) CardViewWrapper(it.gmariotti.cardslib.library.view.base.CardViewWrapper) View(android.view.View) CardGridView(it.gmariotti.cardslib.library.view.CardGridView)

Example 2 with CardViewWrapper

use of it.gmariotti.cardslib.library.view.base.CardViewWrapper in project cardslib by gabrielemariotti.

the class CardGridCursorAdapter method bindView.

@Override
public void bindView(View view, Context context, Cursor cursor) {
    CardViewWrapper mCardView;
    Card mCard;
    mCard = (Card) getCardFromCursor(cursor);
    if (mCard != null) {
        mCardView = (CardViewWrapper) view.findViewById(R.id.list_cardId);
        if (mCardView != null) {
            //It is important to set recycle value for inner layout elements
            mCardView.setForceReplaceInnerLayout(Card.equalsInnerLayout(mCardView.getCard(), mCard));
            //It is important to set recycle value for performance issue
            mCardView.setRecycle(recycle);
            //Save original swipeable to prevent cardSwipeListener (listView requires another cardSwipeListener)
            boolean origianlSwipeable = mCard.isSwipeable();
            mCard.setSwipeable(false);
            mCardView.setCard(mCard);
            //mCard.setSwipeable(origianlSwipeable);
            if (origianlSwipeable)
                Log.d(TAG, "Swipe action not enabled in this type of view");
            //If card has an expandable button override animation
            if (mCard.getCardHeader() != null && mCard.getCardHeader().isButtonExpandVisible()) {
                //setupExpandCollapseListAnimation(mCardView);
                Log.d(TAG, "Expand action not enabled in this type of view");
            }
            //Setup swipeable animation
            setupSwipeableAnimation(mCard, mCardView);
        }
    }
}
Also used : CardViewWrapper(it.gmariotti.cardslib.library.view.base.CardViewWrapper)

Example 3 with CardViewWrapper

use of it.gmariotti.cardslib.library.view.base.CardViewWrapper in project cardslib by gabrielemariotti.

the class BaseDismissAnimation method animateDismissPosition.

public void animateDismissPosition(final Collection<Integer> positions) {
    if (mBaseAdapter == null) {
        throw new IllegalStateException("Call setup method before animate!");
    }
    prepareAnimation();
    final List<Integer> positionsCopy = new ArrayList<Integer>(positions);
    List<CardViewWrapper> views = getVisibleViewsForPositions(positionsCopy);
    for (CardViewWrapper cardView : views) {
        dismissiCardWithAnimation(cardView);
    }
}
Also used : ArrayList(java.util.ArrayList) CardViewWrapper(it.gmariotti.cardslib.library.view.base.CardViewWrapper)

Example 4 with CardViewWrapper

use of it.gmariotti.cardslib.library.view.base.CardViewWrapper in project cardslib by gabrielemariotti.

the class CardArrayAdapter method getView.

// -------------------------------------------------------------
// Views
// -------------------------------------------------------------
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View view = convertView;
    CardViewWrapper mCardView;
    Card mCard;
    LayoutInflater mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    //Retrieve card from items
    mCard = (Card) getItem(position);
    if (mCard != null) {
        int layout = mRowLayoutId;
        boolean recycle = false;
        //Inflate layout
        if (view == null) {
            recycle = false;
            view = mInflater.inflate(layout, parent, false);
        } else {
            recycle = true;
        }
        //Setup card
        mCardView = (CardViewWrapper) view.findViewById(R.id.list_cardId);
        if (mCardView != null) {
            //It is important to set recycle value for inner layout elements
            mCardView.setForceReplaceInnerLayout(Card.equalsInnerLayout(mCardView.getCard(), mCard));
            //It is important to set recycle value for performance issue
            mCardView.setRecycle(recycle);
            //Save original swipeable to prevent cardSwipeListener (listView requires another cardSwipeListener)
            boolean origianlSwipeable = mCard.isSwipeable();
            mCard.setSwipeable(false);
            mCardView.setCard(mCard);
            //Set originalValue
            mCard.setSwipeable(origianlSwipeable);
            //If card has an expandable button override animation
            if ((mCard.getCardHeader() != null && mCard.getCardHeader().isButtonExpandVisible()) || mCard.getViewToClickToExpand() != null) {
                setupExpandCollapseListAnimation(mCardView);
            }
            //Setup swipeable animation
            setupSwipeableAnimation(mCard, mCardView);
            //setupMultiChoice
            setupMultichoice(view, mCard, mCardView, position);
        }
    }
    return view;
}
Also used : LayoutInflater(android.view.LayoutInflater) CardViewWrapper(it.gmariotti.cardslib.library.view.base.CardViewWrapper) 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)

Example 5 with CardViewWrapper

use of it.gmariotti.cardslib.library.view.base.CardViewWrapper in project cardslib by gabrielemariotti.

the class StickyCardArrayAdapter method getHeaderView.

@Override
public View getHeaderView(int position, View convertView, ViewGroup viewGroup) {
    // Build your custom HeaderView
    //In this case I will use a Card, but you can use any view
    LayoutInflater mInflater = LayoutInflater.from(getContext());
    View view = mInflater.inflate(R.layout.carddemo_extras_sticky_header, null);
    CardViewWrapper cardView = (CardViewWrapper) view.findViewById(R.id.carddemo_card_sticky_header_id);
    Card card = getItem(position);
    char headerChar = card.getTitle().subSequence(0, 1).charAt(0);
    ColorCard colorCard = new ColorCard(getContext());
    colorCard.setTitle("Header : " + headerChar);
    switch(position / 8) {
        case 0:
            colorCard.setBackgroundResourceId(R.drawable.demoextra_card_selector_color1);
            break;
        case 1:
            colorCard.setBackgroundResourceId(R.drawable.demoextra_card_selector_color2);
            break;
        case 2:
            colorCard.setBackgroundResourceId(R.drawable.demoextra_card_selector_color3);
            break;
        case 3:
            colorCard.setBackgroundResourceId(R.drawable.demoextra_card_selector_color4);
            break;
        case 4:
            colorCard.setBackgroundResourceId(R.drawable.demoextra_card_selector_color5);
            break;
        default:
            colorCard.setBackgroundResourceId(R.drawable.demoextra_card_selector_color1);
            break;
    }
    cardView.setCard(colorCard);
    return view;
}
Also used : LayoutInflater(android.view.LayoutInflater) CardViewWrapper(it.gmariotti.cardslib.library.view.base.CardViewWrapper) CardListView(it.gmariotti.cardslib.library.view.CardListView) View(android.view.View) ColorCard(it.gmariotti.cardslib.demo.extras.cards.ColorCard) Card(it.gmariotti.cardslib.library.internal.Card) ColorCard(it.gmariotti.cardslib.demo.extras.cards.ColorCard)

Aggregations

CardViewWrapper (it.gmariotti.cardslib.library.view.base.CardViewWrapper)15 View (android.view.View)8 Card (it.gmariotti.cardslib.library.internal.Card)6 LayoutInflater (android.view.LayoutInflater)4 ViewGroup (android.view.ViewGroup)3 CardThumbnailView (it.gmariotti.cardslib.library.view.component.CardThumbnailView)3 SuppressLint (android.annotation.SuppressLint)2 AbsListView (android.widget.AbsListView)2 ListView (android.widget.ListView)2 TextView (android.widget.TextView)2 CardListView (it.gmariotti.cardslib.library.view.CardListView)2 CardHeaderView (it.gmariotti.cardslib.library.view.component.CardHeaderView)2 SwipeDismissViewTouchListener (it.gmariotti.cardslib.library.view.listener.SwipeDismissViewTouchListener)2 ArrayList (java.util.ArrayList)2 AdapterView (android.widget.AdapterView)1 ColorCard (it.gmariotti.cardslib.demo.extras.cards.ColorCard)1 CardGridStaggeredView (it.gmariotti.cardslib.library.extra.staggeredgrid.view.CardGridStaggeredView)1 CardExpandableListView (it.gmariotti.cardslib.library.view.CardExpandableListView)1 CardGridView (it.gmariotti.cardslib.library.view.CardGridView)1 CardView (it.gmariotti.cardslib.library.view.CardView)1