use of it.gmariotti.cardslib.library.internal.Card in project cardslib by gabrielemariotti.
the class NativeListBaseFragment method initCards.
private void initCards() {
ArrayList<Card> cards = new ArrayList<Card>();
for (int i = 0; i < 200; i++) {
CardExample card = new CardExample(getActivity(), "My title " + i, "Inner text " + i);
cards.add(card);
}
CardArrayAdapter mCardArrayAdapter = new CardArrayAdapter(getActivity(), cards);
CardListView listView = (CardListView) getActivity().findViewById(R.id.carddemo_list_base1);
if (listView != null) {
listView.setAdapter(mCardArrayAdapter);
}
}
use of it.gmariotti.cardslib.library.internal.Card in project cardslib by gabrielemariotti.
the class NativeListDifferentInnerBaseFragment method initCards.
private void initCards() {
ArrayList<Card> cards = new ArrayList<Card>();
for (int i = 0; i < 50; i++) {
CardExample card = new CardExample(getActivity(), "My title " + i, "Inner text " + i);
cards.add(card);
CardExample2 cardx = new CardExample2(this.getActivity());
cardx.title = "Application example " + i;
cardx.secondaryTitle = "A company inc..." + i;
cardx.rating = (float) (Math.random() * (5.0));
cardx.count = i;
cards.add(cardx);
MayKnowCard card2 = new MayKnowCard(getActivity());
//Very important with different inner layout
card2.setType(2);
card2.setSwipeable(true);
cards.add(card2);
}
// Provide a custom adapter.
// It is important to set the viewTypeCount
// You have to provide in your card the type value with {@link Card#setType(int)} method.
CardArrayAdapter mCardArrayAdapter = new CardArrayAdapter(getActivity(), cards);
mCardArrayAdapter.setInnerViewTypeCount(3);
// An alternative is to write a own CardArrayAdapter
// MyCardArrayAdapter mCardArrayAdapter = new MyCardArrayAdapter(getActivity(),cards);
CardListView listView = (CardListView) getActivity().findViewById(R.id.carddemo_list_base1);
if (listView != null) {
listView.setAdapter(mCardArrayAdapter);
}
}
use of it.gmariotti.cardslib.library.internal.Card in project cardslib by gabrielemariotti.
the class NativeListExpandCardFragment method initCards.
private void initCards() {
//Init an array of Cards
ArrayList<Card> cards = new ArrayList<Card>();
for (int i = 0; i < 200; i++) {
Card card = init_standard_header_with_expandcollapse_button_custom_area("Header " + i, i);
cards.add(card);
}
CardArrayAdapter mCardArrayAdapter = new CardArrayAdapter(getActivity(), cards);
CardListView listView = (CardListView) getActivity().findViewById(R.id.carddemo_list_expand);
if (listView != null) {
listView.setAdapter(mCardArrayAdapter);
}
}
use of it.gmariotti.cardslib.library.internal.Card in project cardslib by gabrielemariotti.
the class NativeListExpandCardFragment method init_standard_header_with_expandcollapse_button_custom_area.
/**
* This method builds a standard header with a custom expand/collpase
*/
private Card init_standard_header_with_expandcollapse_button_custom_area(String titleHeader, int i) {
//Create a Card
Card card = new Card(getActivity());
//Create a CardHeader
CardHeader header = new CardHeader(getActivity());
//Set the header title
header.setTitle(titleHeader);
//Set visible the expand/collapse button
header.setButtonExpandVisible(true);
//Add Header to card
card.addCardHeader(header);
//This provides a simple (and useless) expand area
CustomExpandCard expand = new CustomExpandCard(getActivity(), i);
//Add Expand Area to Card
card.addCardExpand(expand);
//Just an example to expand a card
if (i == 2 || i == 7 || i == 9)
card.setExpanded(true);
//Swipe
card.setSwipeable(true);
//Animator listener
card.setOnExpandAnimatorEndListener(new Card.OnExpandAnimatorEndListener() {
@Override
public void onExpandEnd(Card card) {
Toast.makeText(getActivity(), "Expand " + card.getCardHeader().getTitle(), Toast.LENGTH_SHORT).show();
}
});
card.setOnCollapseAnimatorEndListener(new Card.OnCollapseAnimatorEndListener() {
@Override
public void onCollapseEnd(Card card) {
Toast.makeText(getActivity(), "Collpase " + card.getCardHeader().getTitle(), Toast.LENGTH_SHORT).show();
}
});
return card;
}
use of it.gmariotti.cardslib.library.internal.Card in project cardslib by gabrielemariotti.
the class NativeListGplayUndoCardFragment method initCards.
private void initCards() {
//Init an array of Cards
ArrayList<Card> cards = new ArrayList<Card>();
for (int i = 0; i < 100; i++) {
GooglePlaySmallCard card = new GooglePlaySmallCard(this.getActivity());
card.setTitle("Application example " + i);
card.setSecondaryTitle("A company inc..." + i);
card.setRating((float) (Math.random() * (5.0)));
card.setId("" + i);
//Only for test, change some icons
if ((i > 10 && i < 15) || (i > 35 && i < 45)) {
card.setResourceIdThumbnail(R.drawable.ic_launcher);
}
card.init();
cards.add(card);
}
mCardArrayAdapter = new CardArrayAdapter(getActivity(), cards);
mCardArrayAdapter.setUndoBarUIElements(new UndoBarController.DefaultUndoBarUIElements() {
@Override
public SwipeDirectionEnabled isEnabledUndoBarSwipeAction() {
return SwipeDirectionEnabled.TOPBOTTOM;
}
@Override
public AnimationType getAnimationType() {
return AnimationType.TOPBOTTOM;
}
});
//Enable undo controller!
mCardArrayAdapter.setEnableUndo(true);
//CardListView listView = (CardListView) getActivity().findViewById(R.id.carddemo_list_gplaycard);
if (mListView != null) {
mListView.setAdapter(mCardArrayAdapter);
}
}
Aggregations