use of it.gmariotti.cardslib.library.internal.CardHeader in project cardslib by gabrielemariotti.
the class CardExpandFragment method init_custom_card_expand_inside.
/**
* This method builds a card with a collpse/expand section inside
*/
private void init_custom_card_expand_inside() {
//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_expand_area_inside));
//Add Header to card
card.addCardHeader(header);
//This provides a simple (and useless) expand area
CardExpandInside expand = new CardExpandInside(getActivity());
card.addCardExpand(expand);
//Set card in the cardView
CardView cardView = (CardView) getActivity().findViewById(R.id.carddemo_example_card_expand5);
ViewToClickToExpand viewToClickToExpand = ViewToClickToExpand.builder().highlightView(false).setupView(cardView);
card.setViewToClickToExpand(viewToClickToExpand);
card.setOnExpandAnimatorEndListener(new Card.OnExpandAnimatorEndListener() {
@Override
public void onExpandEnd(Card card) {
/*
if (mScrollView!=null){
mScrollView.post(new Runnable() {
public void run() {
mScrollView.scrollTo(0, mScrollView.getBottom());
}
});
}*/
}
});
cardView.setCard(card);
}
use of it.gmariotti.cardslib.library.internal.CardHeader in project cardslib by gabrielemariotti.
the class CardFragment method init_simple_card.
/**
* This method builds a simple card
*/
private void init_simple_card() {
//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 the card inner text
card.setTitle(getString(R.string.demo_card_basetitle));
//Set card in the cardView
CardView cardView = (CardView) getActivity().findViewById(R.id.carddemo_card_id);
cardView.setCard(card);
}
use of it.gmariotti.cardslib.library.internal.CardHeader in project cardslib by gabrielemariotti.
the class ListExpandCardFragment method init_standard_header_with_expandcollapse_button_custom_area.
/**
* This method builds a standard header with a custom expand/collpase
*/
private Card init_standard_header_with_expandcollapse_button_custom_area(String titleHeader, int i) {
//Create a Card
Card card = new Card(getActivity());
//Create a CardHeader
CardHeader header = new CardHeader(getActivity());
//Set the header title
header.setTitle(titleHeader);
//Set visible the expand/collapse button
header.setButtonExpandVisible(true);
//Add Header to card
card.addCardHeader(header);
//This provides a simple (and useless) expand area
CustomExpandCard expand = new CustomExpandCard(getActivity(), i);
//Add Expand Area to Card
card.addCardExpand(expand);
//Just an example to expand a card
if (i == 2 || i == 7 || i == 9)
card.setExpanded(true);
//Swipe
card.setSwipeable(true);
//Animator listener
card.setOnExpandAnimatorEndListener(new Card.OnExpandAnimatorEndListener() {
@Override
public void onExpandEnd(Card card) {
Toast.makeText(getActivity(), "Expand " + card.getCardHeader().getTitle(), Toast.LENGTH_SHORT).show();
}
});
card.setOnCollapseAnimatorEndListener(new Card.OnCollapseAnimatorEndListener() {
@Override
public void onCollapseEnd(Card card) {
Toast.makeText(getActivity(), "Collpase " + card.getCardHeader().getTitle(), Toast.LENGTH_SHORT).show();
}
});
return card;
}
use of it.gmariotti.cardslib.library.internal.CardHeader in project cardslib by gabrielemariotti.
the class NativeHeaderFragment method init_standard_header_with_expandcollapse_button.
/**
* This method builds a standard header with base expand/collpase
*/
private void init_standard_header_with_expandcollapse_button() {
//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));
//Set visible the expand/collapse button
header.setButtonExpandVisible(true);
//Add Header to card
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);
//Set card in the CardViewNative
CardViewNative cardViewNative = (CardViewNative) getActivity().findViewById(R.id.carddemo_header_expand);
cardViewNative.setCard(card);
}
use of it.gmariotti.cardslib.library.internal.CardHeader in project cardslib by gabrielemariotti.
the class NativeHeaderFragment method init_standard_header_with_overflow_button_dynamic_menu_without_xml.
/**
* This method builds a standard header with overflow button with a dynamic menu
*/
private void init_standard_header_with_overflow_button_dynamic_menu_without_xml() {
//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));
//Add a popup menu. This method set OverFlow button to visible
header.setButtonOverflowVisible(true);
header.setPopupMenuListener(new CardHeader.OnClickCardHeaderPopupMenuListener() {
@Override
public void onMenuItemClick(BaseCard card, MenuItem item) {
Toast.makeText(getActivity(), "Click on " + item.getTitle() + "-" + ((Card) card).getCardHeader().getTitle(), Toast.LENGTH_SHORT).show();
}
});
//Add a PopupMenuPrepareListener to add dynamically a menu entry
//it is optional.
header.setPopupMenuPrepareListener(new CardHeader.OnPrepareCardHeaderPopupMenuListener() {
@Override
public boolean onPreparePopupMenu(BaseCard card, PopupMenu popupMenu) {
popupMenu.getMenu().add("Dynamic item");
return true;
}
});
card.addCardHeader(header);
//Set card in the CardViewNative
CardViewNative cardViewNative = (CardViewNative) getActivity().findViewById(R.id.carddemo_header_overflow_dynamic2);
cardViewNative.setCard(card);
}
Aggregations