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());
}
}
}
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;
}
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);
}
}
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);
}
}
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);
}
}
}
Aggregations