Search in sources :

Example 6 with CardThumbnail

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();
}
Also used : Crouton(de.keyboardsurfer.android.widget.crouton.Crouton) LayoutInflater(android.view.LayoutInflater) CardView(it.gmariotti.cardslib.library.view.CardView) View(android.view.View) CardView(it.gmariotti.cardslib.library.view.CardView) CardThumbnail(it.gmariotti.cardslib.library.internal.CardThumbnail) Card(it.gmariotti.cardslib.library.internal.Card)

Example 7 with CardThumbnail

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();
}
Also used : Crouton(de.keyboardsurfer.android.widget.crouton.Crouton) LayoutInflater(android.view.LayoutInflater) CardView(it.gmariotti.cardslib.library.view.CardView) View(android.view.View) CardView(it.gmariotti.cardslib.library.view.CardView) CardThumbnail(it.gmariotti.cardslib.library.internal.CardThumbnail) Card(it.gmariotti.cardslib.library.internal.Card)

Example 8 with CardThumbnail

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);
}
Also used : Canvas(android.graphics.Canvas) CardHeader(it.gmariotti.cardslib.library.internal.CardHeader) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Drawable(android.graphics.drawable.Drawable) MenuItem(android.view.MenuItem) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Bitmap(android.graphics.Bitmap) PackageManager(android.content.pm.PackageManager) BaseCard(it.gmariotti.cardslib.library.internal.base.BaseCard) CardThumbnail(it.gmariotti.cardslib.library.internal.CardThumbnail)

Example 9 with CardThumbnail

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);
}
Also used : TextView(android.widget.TextView) View(android.view.View) CardThumbnail(it.gmariotti.cardslib.library.internal.CardThumbnail) Card(it.gmariotti.cardslib.library.internal.Card)

Example 10 with CardThumbnail

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);
}
Also used : CardHeader(it.gmariotti.cardslib.library.internal.CardHeader) CardView(it.gmariotti.cardslib.library.view.CardView) CardThumbnail(it.gmariotti.cardslib.library.internal.CardThumbnail) CustomThumbCard(it.gmariotti.cardslib.demo.cards.CustomThumbCard) Card(it.gmariotti.cardslib.library.internal.Card)

Aggregations

CardThumbnail (it.gmariotti.cardslib.library.internal.CardThumbnail)10 Card (it.gmariotti.cardslib.library.internal.Card)9 CardHeader (it.gmariotti.cardslib.library.internal.CardHeader)6 View (android.view.View)5 CustomThumbCard (it.gmariotti.cardslib.demo.cards.CustomThumbCard)4 CardView (it.gmariotti.cardslib.library.view.CardView)4 TextView (android.widget.TextView)3 LayoutInflater (android.view.LayoutInflater)2 Crouton (de.keyboardsurfer.android.widget.crouton.Crouton)2 CardViewNative (it.gmariotti.cardslib.library.view.CardViewNative)2 PackageManager (android.content.pm.PackageManager)1 Bitmap (android.graphics.Bitmap)1 Canvas (android.graphics.Canvas)1 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 Drawable (android.graphics.drawable.Drawable)1 MenuItem (android.view.MenuItem)1 BaseCard (it.gmariotti.cardslib.library.internal.base.BaseCard)1 CardThumbnailView (it.gmariotti.cardslib.library.view.component.CardThumbnailView)1