use of it.gmariotti.cardslib.library.view.CardViewNative in project cardslib by gabrielemariotti.
the class NativeThumbnailFragment 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
CardViewNative cardView = (CardViewNative) getActivity().findViewById(R.id.carddemo_thumb_url);
cardView.setCard(card);
}
use of it.gmariotti.cardslib.library.view.CardViewNative in project cardslib by gabrielemariotti.
the class NativeThumbnailFragment method init_card_thumb_resourceId.
/**
* This method builds a card with a thumbnail with a resource ID
*/
private void init_card_thumb_resourceId() {
//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 header to a card
card.addCardHeader(header);
//Create thumbnail
CardThumbnail thumb = new CardThumbnail(getActivity());
//Set ID resource
thumb.setDrawableResource(R.drawable.carddemo_ic_gmaps_large);
//Add thumbnail to a card
card.addCardThumbnail(thumb);
//Set card in the cardView
CardViewNative cardView = (CardViewNative) getActivity().findViewById(R.id.carddemo_thumb_id);
cardView.setCard(card);
}
use of it.gmariotti.cardslib.library.view.CardViewNative in project cardslib by gabrielemariotti.
the class NativeThumbnailFragment method init_card_thumb_custom_source.
/**
* This method builds a card with a custom source thumbnail
*/
private void init_card_thumb_custom_source() {
//Create a Card
Card card = new GplayCardCustomSource(getActivity());
//Set card in the cardView
CardViewNative cardView = (CardViewNative) getActivity().findViewById(R.id.carddemo_thumb_customsource);
cardView.setCard(card);
}
use of it.gmariotti.cardslib.library.view.CardViewNative in project cardslib by gabrielemariotti.
the class NativeHeaderFragment method init_standard_header_with_custom_other_button.
/**
* This method builds a standard header with other button visible
*/
private void init_standard_header_with_custom_other_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.setOtherButtonVisible(true);
//Add a callback
header.setOtherButtonClickListener(new CardHeader.OnClickCardHeaderOtherButtonListener() {
@Override
public void onButtonItemClick(Card card, View view) {
Toast.makeText(getActivity(), "Click on Other Button", Toast.LENGTH_LONG).show();
}
});
//Add Header to card
card.addCardHeader(header);
//Set card in the CardViewNative
final CardViewNative cardViewNative = (CardViewNative) getActivity().findViewById(R.id.carddemo_header_other_button);
cardViewNative.setCard(card);
}
use of it.gmariotti.cardslib.library.view.CardViewNative in project cardslib by gabrielemariotti.
the class NativeHeaderFragment method init_standard_header_with_custom_other_button_programmatically.
/**
* This method builds a standard header with other button visible which drawable is defined programmatically
*/
private void init_standard_header_with_custom_other_button_programmatically() {
//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.setOtherButtonVisible(true);
//Add a callback
header.setOtherButtonClickListener(new CardHeader.OnClickCardHeaderOtherButtonListener() {
@Override
public void onButtonItemClick(Card card, View view) {
Toast.makeText(getActivity(), "Click on Other Button", Toast.LENGTH_LONG).show();
}
});
//Use this code to set your drawable
if (Build.VERSION.SDK_INT >= Constants.API_L) {
// Use the simple png. It is the src in image (Android-L uses the ripple)
header.setOtherButtonDrawable(R.drawable.ic_action_add);
} else {
// Use a selector. It is the background in image
header.setOtherButtonDrawable(R.drawable.card_menu_button_other_add);
}
//Add Header to card
card.addCardHeader(header);
//Set card in the CardViewNative
final CardViewNative cardViewNative = (CardViewNative) getActivity().findViewById(R.id.carddemo_header_other_button_programmatically);
cardViewNative.setCard(card);
}
Aggregations