use of it.gmariotti.cardslib.library.internal.CardHeader in project cardslib by gabrielemariotti.
the class NativeCardFragment method init_cab.
/**
* Card with a CAB
*/
private void init_cab() {
// Create a Card
mCardCab = new Card(getActivity());
// Create a CardHeader
CardHeader header = new CardHeader(getActivity());
// Set the header title
header.setTitle(getString(R.string.demo_title_cab1));
mCardCab.addCardHeader(header);
// Set the card inner text
mCardCab.setTitle(getString(R.string.demo_card_basetitle));
// Set onClick listener
mCardCab.setOnLongClickListener(new Card.OnLongCardClickListener() {
@Override
public boolean onLongClick(Card card, View view) {
if (mActionMode != null) {
view.setActivated(false);
mActionMode.finish();
return false;
}
// Start the CAB using the ActionMode.Callback defined above
mActionMode = getActivity().startActionMode(mActionModeCallback);
view.setActivated(true);
return true;
}
});
// Set card in the cardView
cardViewCab = (CardViewNative) getActivity().findViewById(R.id.carddemo_example_card_cab);
cardViewCab.setCard(mCardCab);
}
use of it.gmariotti.cardslib.library.internal.CardHeader in project cardslib by gabrielemariotti.
the class ShadowFragment method init_card_without_shadow.
/**
* This method builds a card without shadow
*/
private void init_card_without_shadow() {
// Create a Card
Card card = new Card(getActivity());
// Create a CardHeader
CardHeader header = new CardHeader(getActivity());
// Set the header title
header.setTitle(getString(R.string.demo_header_basetitle));
card.addCardHeader(header);
// Hidden shadow
card.setShadow(false);
// Set card in the cardView
CardView cardView = (CardView) getActivity().findViewById(R.id.carddemo_shadow_no);
cardView.setCard(card);
}
use of it.gmariotti.cardslib.library.internal.CardHeader in project cardslib by gabrielemariotti.
the class ShadowFragment method init_card_custom_shadow_layout.
/**
* This methods builds a card with a custom shadow layout (compound view)
* <b>WARNING</b>
* See https://github.com/gabrielemariotti/cardslib/tree/master/SHADOW.md for more information.
* You can quickly modify your shadow with your style and drawable files without modifying shadow layout.
*/
private void init_card_custom_shadow_layout() {
// Create a Card
Card card = new Card(getActivity());
// Create a CardHeader
CardHeader header = new CardHeader(getActivity());
// Set the header title
header.setTitle(getString(R.string.demo_header_basetitle));
card.addCardHeader(header);
// Set card in the cardView
CardView cardView = (CardView) getActivity().findViewById(R.id.carddemo_shadow_layout);
cardView.setCard(card);
}
use of it.gmariotti.cardslib.library.internal.CardHeader in project cardslib by gabrielemariotti.
the class ThumbnailFragment method init_card_thumb_resourceURL.
/**
* This method builds a card with a thumbnail with a resource URL
*/
private void init_card_thumb_resourceURL() {
// Create a Card
Card card = new Card(getActivity());
// Create a CardHeader
CardHeader header = new CardHeader(getActivity());
// Set the header title
header.setTitle(getString(R.string.demo_header_basetitle));
card.addCardHeader(header);
// Create thumbnail
CardThumbnail thumb = new CardThumbnail(getActivity());
// Set URL resource
thumb.setUrlResource("https://lh5.googleusercontent.com/-N8bz9q4Kz0I/AAAAAAAAAAI/AAAAAAAAAAs/Icl2bQMyK7c/s265-c-k-no/photo.jpg");
// Error Resource ID
thumb.setErrorResource(R.drawable.ic_error_loadingorangesmall);
// Add thumbnail to a card
card.addCardThumbnail(thumb);
// Set card in the cardView
CardView cardView = (CardView) getActivity().findViewById(R.id.carddemo_thumb_url);
cardView.setCard(card);
}
use of it.gmariotti.cardslib.library.internal.CardHeader in project cardslib by gabrielemariotti.
the class RecyclerViewFragment method initCard.
/**
* This method builds a simple list of cards
*/
private ArrayList<Card> initCard() {
// Init an array of Cards
ArrayList<Card> cards = new ArrayList<Card>();
for (int i = 0; i < 200; i++) {
Card card = new Card(this.getActivity());
card.setTitle("Application example " + i);
// Create a CardHeader
CardHeader header = new CardHeader(getActivity());
// Set the header title
header.setTitle(getString(R.string.demo_header_basetitle));
if (i < 10) {
// Add a popup menu. This method set OverFlow button to visible
header.setPopupMenu(R.menu.popupmain, new CardHeader.OnClickCardHeaderPopupMenuListener() {
@Override
public void onMenuItemClick(BaseCard card, MenuItem item) {
Toast.makeText(getActivity(), "Click on " + item.getTitle(), Toast.LENGTH_SHORT).show();
}
});
card.addCardHeader(header);
} else {
// Set visible the expand/collapse button
header.setButtonExpandVisible(true);
card.addCardHeader(header);
// This provides a simple (and useless) expand area
CardExpand expand = new CardExpand(getActivity());
// Set inner title in Expand Area
expand.setTitle(getString(R.string.demo_expand_basetitle));
card.addCardExpand(expand);
if (i == 12 || i == 17 || i == 19)
card.setExpanded(true);
}
// Add ClickListener
card.setOnClickListener(new Card.OnCardClickListener() {
@Override
public void onClick(Card card, View view) {
Toast.makeText(getActivity(), "Click Listener card=" + card.getTitle(), Toast.LENGTH_SHORT).show();
}
});
cards.add(card);
}
return cards;
}
Aggregations