use of it.gmariotti.cardslib.library.internal.CardArrayAdapter in project cardslib by gabrielemariotti.
the class NativeListGplayCardFragment method initCards.
private void initCards() {
//Init an array of Cards
ArrayList<Card> cards = new ArrayList<Card>();
for (int i = 0; i < 200; 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.count = 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);
}
CardArrayAdapter mCardArrayAdapter = new CardArrayAdapter(getActivity(), cards);
CardListView listView = (CardListView) getActivity().findViewById(R.id.carddemo_list_gplaycard);
if (listView != null) {
listView.setAdapter(mCardArrayAdapter);
}
}
use of it.gmariotti.cardslib.library.internal.CardArrayAdapter in project cardslib by gabrielemariotti.
the class NativeListSectionedCardFragment method initCards.
/**
* Init
*/
private void initCards() {
//Init an array of Cards
ArrayList<Card> cards = new ArrayList<Card>();
for (int i = 0; i < 200; 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.count = i;
card.init();
//Add card to array
cards.add(card);
}
//Standard array
CardArrayAdapter mCardArrayAdapter = new CardArrayAdapter(getActivity(), cards);
// Sections code.
// Add the card sections
List<GplayCardSection> sections = new ArrayList<GplayCardSection>();
sections.add(new GplayCardSection(1, "Section 1", "More"));
sections.add(new GplayCardSection(3, "Section 2", "Other"));
GplayCardSection[] dummy = new GplayCardSection[sections.size()];
//Sectioned adapter
GPlaySectionedAdapter mAdapter = new GPlaySectionedAdapter(getActivity(), mCardArrayAdapter);
mAdapter.setCardSections(sections.toArray(dummy));
CardListView listView = (CardListView) getActivity().findViewById(R.id.carddemo_list_gplaycard);
if (listView != null) {
listView.setExternalAdapter(mAdapter, mCardArrayAdapter);
}
}
use of it.gmariotti.cardslib.library.internal.CardArrayAdapter in project cardslib by gabrielemariotti.
the class CardWithListArrayFragment method initCard.
/**
* This method builds a simple card
*/
private void initCard() {
ArrayList<Card> cards = new ArrayList<Card>();
for (int i = 0; i < 200; i++) {
//Create a Card
GoogleNowWeatherCard card = new GoogleNowWeatherCard(getActivity());
card.init();
cards.add(card);
}
CardArrayAdapter mCardArrayAdapter = new CardArrayAdapter(getActivity(), cards);
CardListView listView = (CardListView) getActivity().findViewById(R.id.carddemo_list_cwl);
if (listView != null) {
listView.setAdapter(mCardArrayAdapter);
}
}
use of it.gmariotti.cardslib.library.internal.CardArrayAdapter in project cardslib by gabrielemariotti.
the class ListBaseFragment 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.CardArrayAdapter in project cardslib by gabrielemariotti.
the class ListDifferentInnerBaseFragment 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);
}
}
Aggregations