Search in sources :

Example 96 with Card

use of it.gmariotti.cardslib.library.internal.Card in project cardslib by gabrielemariotti.

the class CardGridStaggeredArrayAdapter 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()) || mCard.getViewToClickToExpand() != null) {
                //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) CardGridStaggeredView(it.gmariotti.cardslib.library.extra.staggeredgrid.view.CardGridStaggeredView) Card(it.gmariotti.cardslib.library.internal.Card)

Example 97 with Card

use of it.gmariotti.cardslib.library.internal.Card in project cardslib by gabrielemariotti.

the class BaseRecyclerViewAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(CardViewHolder cardViewHolder, int position) {
    CardViewWrapper mCardView = cardViewHolder.mCardView;
    Card mCard = getItem(position);
    //Setup card
    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(cardViewHolder.recycled);
        //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);
    }
}
Also used : CardViewWrapper(it.gmariotti.cardslib.library.view.base.CardViewWrapper) Card(it.gmariotti.cardslib.library.internal.Card)

Example 98 with Card

use of it.gmariotti.cardslib.library.internal.Card in project cardslib by gabrielemariotti.

the class BaseDismissAnimation method animateDismiss.

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

Example 99 with Card

use of it.gmariotti.cardslib.library.internal.Card in project cardslib by gabrielemariotti.

the class MultiChoiceAdapterHelperBase method isCardCheckable.

/**
     * Indicates if the card is checkable
     *
     * @param position
     * @return
     */
public boolean isCardCheckable(int position) {
    MultiChoiceAdapter adapter = (MultiChoiceAdapter) owner;
    Card card = adapter.getItem(position);
    if (card != null)
        return card.isCheckable();
    return false;
}
Also used : Card(it.gmariotti.cardslib.library.internal.Card)

Example 100 with Card

use of it.gmariotti.cardslib.library.internal.Card in project cardslib by gabrielemariotti.

the class MultiChoiceAdapterHelperBase method getSelectedCards.

// -------------------------------------------------------------
// Utility methods
// -------------------------------------------------------------
/**
     * Returns the selected cards
     * @return
     */
public ArrayList<Card> getSelectedCards() {
    SparseBooleanArray checked = mAdapterView.getCheckedItemPositions();
    ArrayList<Card> items = new ArrayList<Card>();
    MultiChoiceAdapter adapter = (MultiChoiceAdapter) owner;
    for (int i = checked.size() - 1; i >= 0; i--) {
        if (checked.valueAt(i) == true) {
            items.add(adapter.getItem((int) checked.keyAt(i)));
        }
    }
    return items;
}
Also used : SparseBooleanArray(android.util.SparseBooleanArray) ArrayList(java.util.ArrayList) Card(it.gmariotti.cardslib.library.internal.Card)

Aggregations

Card (it.gmariotti.cardslib.library.internal.Card)134 ArrayList (java.util.ArrayList)53 CardHeader (it.gmariotti.cardslib.library.internal.CardHeader)51 BaseCard (it.gmariotti.cardslib.library.internal.base.BaseCard)39 View (android.view.View)35 CardView (it.gmariotti.cardslib.library.view.CardView)31 CardViewNative (it.gmariotti.cardslib.library.view.CardViewNative)31 CustomExpandCard (it.gmariotti.cardslib.demo.cards.CustomExpandCard)26 CardArrayAdapter (it.gmariotti.cardslib.library.internal.CardArrayAdapter)26 CardListView (it.gmariotti.cardslib.library.view.CardListView)24 CustomCard (it.gmariotti.cardslib.demo.cards.CustomCard)22 CustomHeaderInnerCard (it.gmariotti.cardslib.demo.cards.CustomHeaderInnerCard)22 ScrollView (android.widget.ScrollView)15 TextView (android.widget.TextView)14 CardExpand (it.gmariotti.cardslib.library.internal.CardExpand)14 MenuItem (android.view.MenuItem)10 CardThumbnail (it.gmariotti.cardslib.library.internal.CardThumbnail)9 CustomThumbCard (it.gmariotti.cardslib.demo.cards.CustomThumbCard)8 PicassoCard (it.gmariotti.cardslib.demo.extras.cards.PicassoCard)7 CardRecyclerView (it.gmariotti.cardslib.library.recyclerview.view.CardRecyclerView)7