Search in sources :

Example 11 with CardViewWrapper

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

the class CardCursorAdapter 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);
            mCard.setExpanded(isExpanded(mCard));
            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);
            }
            //Setup swipeable animation
            setupSwipeableAnimation(mCard, mCardView);
            //setupMultiChoice
            setupMultichoice(view, mCard, mCardView, cursor.getPosition());
        }
    }
}
Also used : CardViewWrapper(it.gmariotti.cardslib.library.view.base.CardViewWrapper)

Example 12 with CardViewWrapper

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

the class CardExpandableListAdapter method getGroupView.

@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
    View view = convertView;
    CardViewWrapper mCardView;
    Card mCard = (Card) getGroup(groupPosition);
    if (mCard != null) {
        int layout = mGroupLayoutId;
        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);
            mCard.setSwipeable(false);
            mCardView.setCard(mCard);
        }
    }
    return view;
}
Also used : CardViewWrapper(it.gmariotti.cardslib.library.view.base.CardViewWrapper) TextView(android.widget.TextView) View(android.view.View) CardExpandableListView(it.gmariotti.cardslib.library.view.CardExpandableListView)

Example 13 with CardViewWrapper

use of it.gmariotti.cardslib.library.view.base.CardViewWrapper 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 14 with CardViewWrapper

use of it.gmariotti.cardslib.library.view.base.CardViewWrapper 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 15 with CardViewWrapper

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

the class MultiChoiceAdapterHelperBase method setupMultichoice.

/**
     * Used to setup some element events for multichoice
     *
     * @param view
     * @param mCard
     * @param mCardView
     * @param position
     */
public void setupMultichoice(View view, Card mCard, CardViewWrapper mCardView, long position) {
    final MultiChoiceAdapter adapter = (MultiChoiceAdapter) owner;
    View.OnClickListener advanceClickListener = new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final CardViewWrapper cardView = (CardViewWrapper) v;
            int position = adapter.getPosition(cardView.getCard());
            onItemClick(mAdapterView, v, position, adapter.getItemId(position));
        }
    };
    //You need it to enable the CAB
    if (mCard.isCheckable()) {
        //mCardView.setLongClickable(true);
        mCardView.setOnClickListener(advanceClickListener);
    } else {
        if (mCard.getOnClickListener() != null) {
            mCardView.setOnClickListener(advanceClickListener);
        }
    }
}
Also used : CardViewWrapper(it.gmariotti.cardslib.library.view.base.CardViewWrapper) AbsListView(android.widget.AbsListView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

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