use of it.gmariotti.cardslib.library.internal.Card in project cardslib by gabrielemariotti.
the class NativeCardFragment method init_custom_card_clickable.
/**
* This method builds a custom card clickable
*/
private void init_custom_card_clickable() {
//Create a Card
CustomCard card = new CustomCard(getActivity());
//Set onClick listener
card.setOnClickListener(new Card.OnCardClickListener() {
@Override
public void onClick(Card card, View view) {
Toast.makeText(getActivity(), "Clickable card", Toast.LENGTH_LONG).show();
}
});
//Set card in the cardView
CardViewNative cardView = (CardViewNative) getActivity().findViewById(R.id.carddemo_example_card3_clickable);
cardView.setCard(card);
}
use of it.gmariotti.cardslib.library.internal.Card in project cardslib by gabrielemariotti.
the class NativeCardExpandFragment 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
CardViewNative cardView = (CardViewNative) 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.Card in project cardslib by gabrielemariotti.
the class NativeCardExpandFragment method init_custom_card_expand_programmatic.
/**
* This method builds a card with a collpse/expand action in programmatic way
*/
private void init_custom_card_expand_programmatic() {
//Create a Card
final Card card = new Card(getActivity());
//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_customtitle3));
card.addCardExpand(expand);
ViewToClickToExpand viewToClickToExpand = ViewToClickToExpand.builder().enableForExpandAction();
card.setViewToClickToExpand(viewToClickToExpand);
TextView tx = (TextView) getActivity().findViewById(R.id.carddemo_example_card_expand6_text);
tx.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
card.doToogleExpand();
}
});
//Set card in the cardView
CardViewNative cardView = (CardViewNative) getActivity().findViewById(R.id.carddemo_example_card_expand6);
cardView.setCard(card);
}
use of it.gmariotti.cardslib.library.internal.Card in project cardslib by gabrielemariotti.
the class GoogleNowBirthCard method init.
private void init() {
//Add Header
GoogleNowBirthHeader header = new GoogleNowBirthHeader(getContext(), R.layout.carddemo_googlenowbirth_inner_header);
header.setButtonExpandVisible(true);
header.mName = "Gabriele Mariotti";
header.mSubName = "Birthday today";
addCardHeader(header);
//Add Expand Area
CardExpand expand = new GoogleNowExpandCard(getContext());
addCardExpand(expand);
//Set clickListener
setOnClickListener(new OnCardClickListener() {
@Override
public void onClick(Card card, View view) {
Toast.makeText(getContext(), "Click Listener card", Toast.LENGTH_LONG).show();
}
});
//Add Thumbnail
GoogleNowBirthThumb thumbnail = new GoogleNowBirthThumb(getContext());
float density = getContext().getResources().getDisplayMetrics().density;
int size = (int) (125 * density);
thumbnail.setUrlResource("https://lh5.googleusercontent.com/-squZd7FxR8Q/UyN5UrsfkqI/AAAAAAAAbAo/VoDHSYAhC_E/s" + size + "/new%2520profile%2520%25282%2529.jpg");
thumbnail.setErrorResource(R.drawable.ic_ic_error_loading);
addCardThumbnail(thumbnail);
}
use of it.gmariotti.cardslib.library.internal.Card in project cardslib by gabrielemariotti.
the class GoogleNowStockCard method init.
private void init() {
//Add Header
CardHeader header = new CardHeader(getContext());
header.setButtonExpandVisible(true);
//should use R.string.
header.setTitle("Stocks today");
addCardHeader(header);
//Add expand
CardExpand expand = new GoogleNowExpandCard(getContext());
addCardExpand(expand);
//Add onClick Listener
setOnClickListener(new OnCardClickListener() {
@Override
public void onClick(Card card, View view) {
Toast.makeText(getContext(), "Click Listener card=", Toast.LENGTH_LONG).show();
}
});
//Add swipe Listener
setOnSwipeListener(new OnSwipeListener() {
@Override
public void onSwipe(Card card) {
Toast.makeText(getContext(), "Card removed", Toast.LENGTH_LONG).show();
}
});
}
Aggregations