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();
}
use of it.gmariotti.cardslib.library.internal.Card in project cardslib by gabrielemariotti.
the class GoogleProgressFragment 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 < 20; i++) {
GoogleProgressBarCard card = new GoogleProgressBarCard(this.getActivity());
card.setTitle("A simple card loaded with Picasso " + i);
card.setSecondaryTitle("Simple text..." + i);
card.setCount(i);
card.setId("" + i);
card.setProgressBarViewStubLayoutId(R.layout.carddemo_native_smoothprogress);
card.setUseProgressBar(true);
cards.add(card);
}
//Set the adapter
mCardArrayAdapter = new CardArrayRecyclerViewAdapter(getActivity(), cards);
CardRecyclerView mRecyclerView = (CardRecyclerView) getActivity().findViewById(R.id.carddemo_extras_recycler_progress);
mRecyclerView.setHasFixedSize(false);
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
//Set the empty view
if (mRecyclerView != null) {
mRecyclerView.setAdapter(mCardArrayAdapter);
}
}
use of it.gmariotti.cardslib.library.internal.Card in project cardslib by gabrielemariotti.
the class NativeDragDropListFragment 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++) {
PicassoCard card = new PicassoCard(this.getActivity());
card.setTitle("A simple card loaded with Picasso " + i);
card.setSecondaryTitle("Simple text..." + i);
card.setCount(i);
//Card must have a stable Id.
card.setId("a" + i);
card.setSwipeable(true);
cards.add(card);
}
//Set the adapter
mCardArrayAdapter = new CardDragDropArrayAdapter(getActivity(), cards);
mListView = (CardListDragDropView) getActivity().findViewById(R.id.carddemo_extra_list_dragdrop);
if (mListView != null) {
mListView.setAdapter(mCardArrayAdapter);
}
//Listener
mListView.setOnItemMovedListener(new OnItemMovedListener() {
@Override
public void onItemMoved(int originalPosition, int newPosition) {
Card card = mCardArrayAdapter.getItem(newPosition);
Toast.makeText(getActivity(), "Card " + card.getId() + " moved to position " + newPosition, Toast.LENGTH_SHORT).show();
}
});
}
Aggregations