use of it.gmariotti.cardslib.library.internal.Card 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;
}
use of it.gmariotti.cardslib.library.internal.Card in project cardslib by gabrielemariotti.
the class AnimateStaggeredGridFragment method onActivityCreated.
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
hideList(false);
//Set the arrayAdapter
ArrayList<Card> cards = new ArrayList<Card>();
mCardArrayAdapter = new CardGridStaggeredArrayAdapter(getActivity(), cards);
staggeredView = (CardGridStaggeredView) getActivity().findViewById(R.id.carddemo_extras_grid_stag);
//Load cards
new LoaderAsyncTask().execute();
//Set the empty view
staggeredView.setEmptyView(getActivity().findViewById(android.R.id.empty));
/**
* Set adapter with animations
*/
if (staggeredView != null) {
setAlphaAdapter();
}
}
use of it.gmariotti.cardslib.library.internal.Card in project cardslib by gabrielemariotti.
the class BaseStaggeredGridFragment method initCard.
/**
* This method builds a simple list of cards
*/
private void initCard() {
//Only for test scope, use 6 different header titles
int[] resTitleId = { R.string.carddemo_extras_title_base_stag1, R.string.carddemo_extras_title_base_stag2, R.string.carddemo_extras_title_base_stag3, R.string.carddemo_extras_title_base_stag4, R.string.carddemo_extras_title_base_stag5, R.string.carddemo_extras_title_base_stag6 };
//Init an array of Cards
ArrayList<Card> cards = new ArrayList<Card>();
for (int i = 0; i < 200; i++) {
SquareGridCard card = new SquareGridCard(getActivity());
card.headerTitle = "Card " + i;
//Only for test scope, use random colors, and random height
int random = (int) (Math.random() * 6);
card.mainContent = getString(resTitleId[random]);
if ((random / 2 % 3 == 0)) {
card.thumbHeightId = R.dimen.carddemo_extras_basestaggered_height1;
} else if ((random / 2 % 3 == 1)) {
card.thumbHeightId = R.dimen.carddemo_extras_basestaggered_height2;
} else if ((random / 2 % 3 == 2)) {
card.thumbHeightId = R.dimen.carddemo_extras_basestaggered_height3;
}
//Only for test, change background color
if ((i % 5 == 0)) {
card.color = R.color.demoextra_card_background_color1;
} else if ((i % 5 == 1)) {
card.color = R.color.demoextra_card_background_color2;
} else if ((i % 5 == 2)) {
card.color = R.color.demoextra_card_background_color3;
} else if ((i % 5 == 3)) {
card.color = R.color.demoextra_card_background_color4;
} else if ((i % 5 == 4)) {
card.color = R.color.demoextra_card_background_color5;
}
card.init();
cards.add(card);
}
//Set the arrayAdapter
CardGridStaggeredArrayAdapter mCardArrayAdapter = new CardGridStaggeredArrayAdapter(getActivity(), cards);
CardGridStaggeredView mGridView = (CardGridStaggeredView) getActivity().findViewById(R.id.carddemo_extras_grid_stag);
if (mGridView != null) {
mGridView.setAdapter(mCardArrayAdapter);
}
}
use of it.gmariotti.cardslib.library.internal.Card in project cardslib by gabrielemariotti.
the class CroutonFragment method crouton2.
/**
* This method builds another crouton card
*/
private void crouton2() {
LayoutInflater mInflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = mInflater.inflate(R.layout.carddemo_extras_crouton_card, null);
//Card View
CardView cardView = (CardView) view.findViewById(R.id.carddemo_card_crouton_id);
//Card
Card card = new Card(getActivity());
card.setTitle("Crouton Card");
//Add a CardThumbnail
CardThumbnail thumb = new CardThumbnail(getActivity());
thumb.setDrawableResource(R.drawable.ic_action_halt);
card.addCardThumbnail(thumb);
cardView.setCard(card);
//Make the crouton view
final Crouton crouton;
crouton = Crouton.make(getActivity(), view);
crouton.show();
}
use of it.gmariotti.cardslib.library.internal.Card in project cardslib by gabrielemariotti.
the class CroutonFragment method crouton1.
/**
* This method builds a crouton card
*/
private void crouton1() {
LayoutInflater mInflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = mInflater.inflate(R.layout.carddemo_extras_crouton_card, null);
//CardView
CardView cardView = (CardView) view.findViewById(R.id.carddemo_card_crouton_id);
//Card
Card card = new Card(getActivity());
card.setTitle("Crouton Card");
card.setBackgroundResourceId(R.color.demoextra_card_background_color2);
//Add a cardThumbnail
CardThumbnail thumb = new CardThumbnail(getActivity());
thumb.setDrawableResource(R.drawable.ic_action_bulb);
card.addCardThumbnail(thumb);
cardView.setCard(card);
//Make the crouton view
final Crouton crouton;
crouton = Crouton.make(getActivity(), view);
crouton.show();
}
Aggregations