Search in sources :

Example 86 with 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_extras_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());
    //You need to set true to use an external library
    thumbnail.setExternalUsage(true);
    addCardThumbnail(thumbnail);
}
Also used : CardExpand(it.gmariotti.cardslib.library.internal.CardExpand) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) Card(it.gmariotti.cardslib.library.internal.Card)

Example 87 with Card

use of it.gmariotti.cardslib.library.internal.Card in project cardslib by gabrielemariotti.

the class DragDropListFragment method initCard.

/**
     * This method builds a simple list of cards
     */
private void initCard() {
    //Init an array of Cards
    ArrayList<Card> cards = new ArrayList<Card>();
    for (int i = 0; i < 25; i++) {
        PicassoCard card = new PicassoCard(this.getActivity());
        card.setTitle("A simple card loaded with Picasso " + i);
        card.setSecondaryTitle("Simple text..." + i);
        card.setCount(i);
        //Card must have a stable Id.
        card.setId("a" + i);
        card.setSwipeable(true);
        cards.add(card);
    }
    //Set the adapter
    mCardArrayAdapter = new CardDragDropArrayAdapter(getActivity(), cards);
    mListView = (CardListDragDropView) getActivity().findViewById(R.id.carddemo_extra_list_dragdrop);
    if (mListView != null) {
        mListView.setAdapter(mCardArrayAdapter);
    }
    //Listener
    mListView.setOnItemMovedListener(new OnItemMovedListener() {

        @Override
        public void onItemMoved(int originalPosition, int newPosition) {
            Card card = mCardArrayAdapter.getItem(newPosition);
            Toast.makeText(getActivity(), "Card " + card.getId() + " moved to position " + newPosition, Toast.LENGTH_SHORT).show();
        }
    });
}
Also used : OnItemMovedListener(com.nhaarman.listviewanimations.itemmanipulation.dragdrop.OnItemMovedListener) ArrayList(java.util.ArrayList) CardDragDropArrayAdapter(it.gmariotti.cardslib.library.extra.dragdroplist.internal.CardDragDropArrayAdapter) PicassoCard(it.gmariotti.cardslib.demo.extras.cards.PicassoCard) PicassoCard(it.gmariotti.cardslib.demo.extras.cards.PicassoCard) Card(it.gmariotti.cardslib.library.internal.Card)

Example 88 with Card

use of it.gmariotti.cardslib.library.internal.Card in project cardslib by gabrielemariotti.

the class ExpandPicassoFragment method initCard.

/**
     * This method builds a simple cards list
     */
private void initCard() {
    //Only for test scope, use images on assets folder
    String[] fileName = { "file:///android_asset/images/sea.jpg", "file:///android_asset/images/snow.jpg", "file:///android_asset/images/water.jpg", "file:///android_asset/images/img2.jpg", "file:///android_asset/images/rose.jpg" };
    //Only for test scope, use 5 different header titles
    int[] resTitleId = { R.string.carddemo_extras_header_expand_area_inside_sea, R.string.carddemo_extras_header_expand_area_inside_snow, R.string.carddemo_extras_header_expand_area_inside_water, R.string.carddemo_extras_header_expand_area_inside_img2, R.string.carddemo_extras_header_expand_area_inside_rose };
    //Remove debugging from Picasso
    Picasso.with(getActivity()).setDebugging(false);
    //Init an array of Cards
    ArrayList<Card> cards = new ArrayList<Card>();
    for (int j = 1; j < 30; j++) {
        for (int i = 0; i < 10; i++) {
            //Card
            CardInside card = new CardInside(this.getActivity());
            //Create a CardHeader
            CardHeader header = new CardHeader(getActivity(), R.layout.carddemo_extras_expandinside_inner_base_header);
            if (i % 2 == 0) {
                //Set the header title
                header.setTitle(getString(resTitleId[(int) (i / 2) % 5]));
                //Add Header to card
                card.addCardHeader(header);
                //Add an expand area
                CardExpandInside expand = new CardExpandInside(getActivity(), fileName[(int) (i / 2) % 5]);
                card.addCardExpand(expand);
            } else {
                //Set the header title
                header.setTitle(getString(R.string.carddemo_extras_header_expand_area_inside));
                //Add Header to card
                card.addCardHeader(header);
                //Only for test scope, use a random number
                int randomNumber = (int) (Math.random() * 6);
                //Add an expand area
                CardExpandInsideSquare expand = new CardExpandInsideSquare(getActivity(), randomNumber);
                card.addCardExpand(expand);
            }
            //Add a viewToClickExpand to enable click on whole card
            ViewToClickToExpand viewToClickToExpand = ViewToClickToExpand.builder().highlightView(false).setupCardElement(ViewToClickToExpand.CardElementUI.CARD);
            card.setViewToClickToExpand(viewToClickToExpand);
            cards.add(card);
        }
    }
    //Set the arrayAdapter
    CardArrayAdapter mCardArrayAdapter = new CardArrayAdapter(getActivity(), cards);
    CardListView listView = (CardListView) getActivity().findViewById(R.id.carddemo_extra_list_mixinside);
    //Add an animator
    AnimationAdapter animCardArrayAdapter = new AlphaInAnimationAdapter(mCardArrayAdapter);
    animCardArrayAdapter.setAbsListView(listView);
    //animCardArrayAdapter.setInitialDelayMillis(500);
    if (listView != null) {
        listView.setExternalAdapter(animCardArrayAdapter, mCardArrayAdapter);
    }
}
Also used : ViewToClickToExpand(it.gmariotti.cardslib.library.internal.ViewToClickToExpand) AlphaInAnimationAdapter(com.nhaarman.listviewanimations.appearance.simple.AlphaInAnimationAdapter) ArrayList(java.util.ArrayList) CardHeader(it.gmariotti.cardslib.library.internal.CardHeader) CardArrayAdapter(it.gmariotti.cardslib.library.internal.CardArrayAdapter) Card(it.gmariotti.cardslib.library.internal.Card) CardListView(it.gmariotti.cardslib.library.view.CardListView) AlphaInAnimationAdapter(com.nhaarman.listviewanimations.appearance.simple.AlphaInAnimationAdapter) AnimationAdapter(com.nhaarman.listviewanimations.appearance.AnimationAdapter)

Example 89 with Card

use of it.gmariotti.cardslib.library.internal.Card in project cardslib by gabrielemariotti.

the class NativePicassoFragment method initCard.

/**
     * This method builds a simple list of cards
     */
private void initCard() {
    //Init an array of Cards
    ArrayList<Card> cards = new ArrayList<Card>();
    for (int i = 0; i < 200; i++) {
        PicassoCard card = new PicassoCard(this.getActivity());
        card.setTitle("A simple card loaded with Picasso " + i);
        card.setSecondaryTitle("Simple text..." + i);
        card.setCount(i);
        cards.add(card);
    }
    //Set the adapter
    CardArrayAdapter mCardArrayAdapter = new CardArrayAdapter(getActivity(), cards);
    CardListView listView = (CardListView) getActivity().findViewById(R.id.carddemo_extra_list_picasso);
    if (listView != null) {
        listView.setAdapter(mCardArrayAdapter);
    }
}
Also used : CardListView(it.gmariotti.cardslib.library.view.CardListView) ArrayList(java.util.ArrayList) CardArrayAdapter(it.gmariotti.cardslib.library.internal.CardArrayAdapter) PicassoCard(it.gmariotti.cardslib.demo.extras.cards.PicassoCard) PicassoCard(it.gmariotti.cardslib.demo.extras.cards.PicassoCard) Card(it.gmariotti.cardslib.library.internal.Card)

Example 90 with Card

use of it.gmariotti.cardslib.library.internal.Card in project cardslib by gabrielemariotti.

the class List2wayFragment method initCard.

/**
     * This method builds a simple list of cards
     */
private ArrayList<Card> initCard() {
    //Init an array of Cards
    ArrayList<Card> cards = new ArrayList<Card>();
    for (int i = 0; i < 200; i++) {
        PicassoCard card = new PicassoCard(this.getActivity());
        card.setTitle("A simple card loaded with Picasso " + i);
        card.setSecondaryTitle("Simple text..." + i);
        card.setCount(i);
        cards.add(card);
    }
    return cards;
}
Also used : ArrayList(java.util.ArrayList) PicassoCard(it.gmariotti.cardslib.demo.extras.cards.PicassoCard) PicassoCard(it.gmariotti.cardslib.demo.extras.cards.PicassoCard) Card(it.gmariotti.cardslib.library.internal.Card)

Aggregations

Card (it.gmariotti.cardslib.library.internal.Card)134 ArrayList (java.util.ArrayList)53 CardHeader (it.gmariotti.cardslib.library.internal.CardHeader)51 BaseCard (it.gmariotti.cardslib.library.internal.base.BaseCard)39 View (android.view.View)35 CardView (it.gmariotti.cardslib.library.view.CardView)31 CardViewNative (it.gmariotti.cardslib.library.view.CardViewNative)31 CustomExpandCard (it.gmariotti.cardslib.demo.cards.CustomExpandCard)26 CardArrayAdapter (it.gmariotti.cardslib.library.internal.CardArrayAdapter)26 CardListView (it.gmariotti.cardslib.library.view.CardListView)24 CustomCard (it.gmariotti.cardslib.demo.cards.CustomCard)22 CustomHeaderInnerCard (it.gmariotti.cardslib.demo.cards.CustomHeaderInnerCard)22 ScrollView (android.widget.ScrollView)15 TextView (android.widget.TextView)14 CardExpand (it.gmariotti.cardslib.library.internal.CardExpand)14 MenuItem (android.view.MenuItem)10 CardThumbnail (it.gmariotti.cardslib.library.internal.CardThumbnail)9 CustomThumbCard (it.gmariotti.cardslib.demo.cards.CustomThumbCard)8 PicassoCard (it.gmariotti.cardslib.demo.extras.cards.PicassoCard)7 CardRecyclerView (it.gmariotti.cardslib.library.recyclerview.view.CardRecyclerView)7