use of it.gmariotti.cardslib.library.internal.CardArrayAdapter in project cardslib by gabrielemariotti.
the class ListViewAnimationsFragment method initCard.
/**
* This method builds a simple list of cards
*/
private void initCard() {
//Init an array of Cards
ArrayList<Card> cards = new ArrayList<Card>();
for (int i = 0; i < 25; i++) {
ColorCard card = new ColorCard(this.getActivity());
//Only for test scope, use different titles and colors
card.setTitle("A simple colored card " + i);
card.setCount(i);
switch(i % 5) {
case 0:
card.setBackgroundResourceId(R.drawable.demoextra_card_selector_color1);
break;
case 1:
card.setBackgroundResourceId(R.drawable.demoextra_card_selector_color2);
break;
case 2:
card.setBackgroundResourceId(R.drawable.demoextra_card_selector_color3);
break;
case 3:
card.setBackgroundResourceId(R.drawable.demoextra_card_selector_color4);
break;
case 4:
card.setBackgroundResourceId(R.drawable.demoextra_card_selector_color5);
break;
}
cards.add(card);
}
//Set the adapter
mCardArrayAdapter = new CardArrayAdapter(getActivity(), cards);
mListView = (CardListView) getActivity().findViewById(R.id.carddemo_extra_list_viewanimations);
if (mListView != null) {
setAlphaAdapter();
}
}
use of it.gmariotti.cardslib.library.internal.CardArrayAdapter in project cardslib by gabrielemariotti.
the class ExpandPicassoFragment method initCard.
/**
* This method builds a simple cards list
*/
private void initCard() {
//Only for test scope, use images on assets folder
String[] fileName = { "file:///android_asset/images/sea.jpg", "file:///android_asset/images/snow.jpg", "file:///android_asset/images/water.jpg", "file:///android_asset/images/img2.jpg", "file:///android_asset/images/rose.jpg" };
//Only for test scope, use 5 different header titles
int[] resTitleId = { R.string.carddemo_extras_header_expand_area_inside_sea, R.string.carddemo_extras_header_expand_area_inside_snow, R.string.carddemo_extras_header_expand_area_inside_water, R.string.carddemo_extras_header_expand_area_inside_img2, R.string.carddemo_extras_header_expand_area_inside_rose };
//Remove debugging from Picasso
Picasso.with(getActivity()).setDebugging(false);
//Init an array of Cards
ArrayList<Card> cards = new ArrayList<Card>();
for (int j = 1; j < 30; j++) {
for (int i = 0; i < 10; i++) {
//Card
CardInside card = new CardInside(this.getActivity());
//Create a CardHeader
CardHeader header = new CardHeader(getActivity(), R.layout.carddemo_extras_expandinside_inner_base_header);
if (i % 2 == 0) {
//Set the header title
header.setTitle(getString(resTitleId[(int) (i / 2) % 5]));
//Add Header to card
card.addCardHeader(header);
//Add an expand area
CardExpandInside expand = new CardExpandInside(getActivity(), fileName[(int) (i / 2) % 5]);
card.addCardExpand(expand);
} else {
//Set the header title
header.setTitle(getString(R.string.carddemo_extras_header_expand_area_inside));
//Add Header to card
card.addCardHeader(header);
//Only for test scope, use a random number
int randomNumber = (int) (Math.random() * 6);
//Add an expand area
CardExpandInsideSquare expand = new CardExpandInsideSquare(getActivity(), randomNumber);
card.addCardExpand(expand);
}
//Add a viewToClickExpand to enable click on whole card
ViewToClickToExpand viewToClickToExpand = ViewToClickToExpand.builder().highlightView(false).setupCardElement(ViewToClickToExpand.CardElementUI.CARD);
card.setViewToClickToExpand(viewToClickToExpand);
cards.add(card);
}
}
//Set the arrayAdapter
CardArrayAdapter mCardArrayAdapter = new CardArrayAdapter(getActivity(), cards);
CardListView listView = (CardListView) getActivity().findViewById(R.id.carddemo_extra_list_mixinside);
//Add an animator
AnimationAdapter animCardArrayAdapter = new AlphaInAnimationAdapter(mCardArrayAdapter);
animCardArrayAdapter.setAbsListView(listView);
//animCardArrayAdapter.setInitialDelayMillis(500);
if (listView != null) {
listView.setExternalAdapter(animCardArrayAdapter, mCardArrayAdapter);
}
}
use of it.gmariotti.cardslib.library.internal.CardArrayAdapter in project cardslib by gabrielemariotti.
the class NativePicassoFragment method initCard.
/**
* This method builds a simple list of cards
*/
private void initCard() {
//Init an array of Cards
ArrayList<Card> cards = new ArrayList<Card>();
for (int i = 0; i < 200; i++) {
PicassoCard card = new PicassoCard(this.getActivity());
card.setTitle("A simple card loaded with Picasso " + i);
card.setSecondaryTitle("Simple text..." + i);
card.setCount(i);
cards.add(card);
}
//Set the adapter
CardArrayAdapter mCardArrayAdapter = new CardArrayAdapter(getActivity(), cards);
CardListView listView = (CardListView) getActivity().findViewById(R.id.carddemo_extra_list_picasso);
if (listView != null) {
listView.setAdapter(mCardArrayAdapter);
}
}
use of it.gmariotti.cardslib.library.internal.CardArrayAdapter in project cardslib by gabrielemariotti.
the class NativeFabFragment method onActivityCreated.
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
hideList(false);
//Set the arrayAdapter
ArrayList<Card> cards = new ArrayList<Card>();
mCardArrayAdapter = new CardArrayAdapter(getActivity(), cards);
CardListView listView = (CardListView) getActivity().findViewById(R.id.carddemo_list_base1);
if (listView != null) {
listView.setAdapter(mCardArrayAdapter);
}
FloatingActionButton floatingActionButton = (FloatingActionButton) getActivity().findViewById(R.id.button_floating_action);
floatingActionButton.attachToListView(listView);
//Load cards
new LoaderAsyncTask().execute();
}
use of it.gmariotti.cardslib.library.internal.CardArrayAdapter in project cardslib by gabrielemariotti.
the class NativeListColorFragment method initCards.
private void initCards() {
//Init an array of Cards
ArrayList<Card> cards = new ArrayList<Card>();
for (int i = 0; i < 5; i++) {
ColorCard card = new ColorCard(this.getActivity());
card.setTitle("A simple colored card " + i);
card.setCount(i);
switch(i) {
case 0:
card.setBackgroundColorResourceId(R.color.demo_card_background_color5);
break;
case 1:
card.setBackgroundColorResourceId(R.color.demo_card_background_color4);
break;
case 2:
card.setBackgroundColorResourceId(R.color.demo_card_background_color3);
break;
case 3:
card.setBackgroundColorResourceId(R.color.demo_card_background_color2);
break;
case 4:
card.setBackgroundColorResourceId(R.color.demo_card_background_color1);
break;
}
cards.add(card);
}
CardArrayAdapter mCardArrayAdapter = new CardArrayAdapter(getActivity(), cards);
CardListView listView = (CardListView) getActivity().findViewById(R.id.carddemo_list_colors);
if (listView != null) {
listView.setAdapter(mCardArrayAdapter);
}
}
Aggregations