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