use of it.gmariotti.cardslib.library.internal.CardThumbnail 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.CardThumbnail 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.CardThumbnail in project cardslib by gabrielemariotti.
the class GplayCardCustomSource method init.
private void init() {
CardHeader header = new CardHeader(getContext());
header.setButtonOverflowVisible(true);
header.setTitle("Google Maps");
header.setPopupMenu(R.menu.popupmain, new CardHeader.OnClickCardHeaderPopupMenuListener() {
@Override
public void onMenuItemClick(BaseCard card, MenuItem item) {
Toast.makeText(getContext(), item.getTitle(), Toast.LENGTH_SHORT).show();
}
});
addCardHeader(header);
CardThumbnail thumbnail = new CardThumbnail(getContext());
thumbnail.setCustomSource(new CardThumbnail.CustomSource() {
@Override
public String getTag() {
return "com.google.android.apps.maps";
}
@Override
public Bitmap getBitmap() {
PackageManager pm = mContext.getPackageManager();
Bitmap bitmap = null;
try {
bitmap = drawableToBitmap(pm.getApplicationIcon(getTag()));
} catch (PackageManager.NameNotFoundException e) {
}
return bitmap;
}
private Bitmap drawableToBitmap(Drawable drawable) {
if (drawable instanceof BitmapDrawable) {
return ((BitmapDrawable) drawable).getBitmap();
}
Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
drawable.draw(canvas);
return bitmap;
}
});
addCardThumbnail(thumbnail);
}
use of it.gmariotti.cardslib.library.internal.CardThumbnail in project cardslib by gabrielemariotti.
the class SuggestedCardThumb method init.
private void init() {
//Add a header
SuggestedCardHeader header = new SuggestedCardHeader(getContext());
addCardHeader(header);
//Set click listener
setOnClickListener(new OnCardClickListener() {
@Override
public void onClick(Card card, View view) {
Toast.makeText(getContext(), "Click listener", Toast.LENGTH_LONG).show();
}
});
//Set swipe on
setSwipeable(true);
//Add thumbnail
CardThumbnail thumb = new SuggestedCardThumb(getContext());
thumb.setUrlResource("https://lh5.googleusercontent.com/-N8bz9q4Kz0I/AAAAAAAAAAI/AAAAAAAAAAs/Icl2bQMyK7c/s265-c-k-no/photo.jpg");
thumb.setErrorResource(R.drawable.ic_error_loadingorangesmall);
addCardThumbnail(thumb);
}
use of it.gmariotti.cardslib.library.internal.CardThumbnail in project cardslib by gabrielemariotti.
the class ThumbnailFragment 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
CardView cardView = (CardView) getActivity().findViewById(R.id.carddemo_thumb_id);
cardView.setCard(card);
}
Aggregations