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