Search in sources :

Example 1 with ColorCard

use of it.gmariotti.cardslib.demo.extras.cards.ColorCard in project cardslib by gabrielemariotti.

the class ActionbarpullFragment 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++) {
        ColorCard card = new ColorCard(this.getActivity());
        //Only for test scope, use different titles and colors
        card.setTitle("A simple colored card " + i);
        card.setCount(i);
        switch(i % 5) {
            case 0:
                card.setBackgroundResourceId(R.drawable.demoextra_card_selector_color1);
                break;
            case 1:
                card.setBackgroundResourceId(R.drawable.demoextra_card_selector_color2);
                break;
            case 2:
                card.setBackgroundResourceId(R.drawable.demoextra_card_selector_color3);
                break;
            case 3:
                card.setBackgroundResourceId(R.drawable.demoextra_card_selector_color4);
                break;
            case 4:
                card.setBackgroundResourceId(R.drawable.demoextra_card_selector_color5);
                break;
        }
        cards.add(card);
    }
    //Set the adapter
    CardArrayAdapter mCardArrayAdapter = new CardArrayAdapter(getActivity(), cards);
    if (listView != null) {
        listView.setAdapter(mCardArrayAdapter);
    }
}
Also used : ArrayList(java.util.ArrayList) CardArrayAdapter(it.gmariotti.cardslib.library.internal.CardArrayAdapter) ColorCard(it.gmariotti.cardslib.demo.extras.cards.ColorCard) Card(it.gmariotti.cardslib.library.internal.Card) ColorCard(it.gmariotti.cardslib.demo.extras.cards.ColorCard)

Example 2 with ColorCard

use of it.gmariotti.cardslib.demo.extras.cards.ColorCard in project cardslib by gabrielemariotti.

the class StickyCardArrayAdapter method getHeaderView.

@Override
public View getHeaderView(int position, View convertView, ViewGroup viewGroup) {
    // Build your custom HeaderView
    //In this case I will use a Card, but you can use any view
    LayoutInflater mInflater = LayoutInflater.from(getContext());
    View view = mInflater.inflate(R.layout.carddemo_extras_sticky_header, null);
    CardViewWrapper cardView = (CardViewWrapper) view.findViewById(R.id.carddemo_card_sticky_header_id);
    Card card = getItem(position);
    char headerChar = card.getTitle().subSequence(0, 1).charAt(0);
    ColorCard colorCard = new ColorCard(getContext());
    colorCard.setTitle("Header : " + headerChar);
    switch(position / 8) {
        case 0:
            colorCard.setBackgroundResourceId(R.drawable.demoextra_card_selector_color1);
            break;
        case 1:
            colorCard.setBackgroundResourceId(R.drawable.demoextra_card_selector_color2);
            break;
        case 2:
            colorCard.setBackgroundResourceId(R.drawable.demoextra_card_selector_color3);
            break;
        case 3:
            colorCard.setBackgroundResourceId(R.drawable.demoextra_card_selector_color4);
            break;
        case 4:
            colorCard.setBackgroundResourceId(R.drawable.demoextra_card_selector_color5);
            break;
        default:
            colorCard.setBackgroundResourceId(R.drawable.demoextra_card_selector_color1);
            break;
    }
    cardView.setCard(colorCard);
    return view;
}
Also used : LayoutInflater(android.view.LayoutInflater) CardViewWrapper(it.gmariotti.cardslib.library.view.base.CardViewWrapper) CardListView(it.gmariotti.cardslib.library.view.CardListView) View(android.view.View) ColorCard(it.gmariotti.cardslib.demo.extras.cards.ColorCard) Card(it.gmariotti.cardslib.library.internal.Card) ColorCard(it.gmariotti.cardslib.demo.extras.cards.ColorCard)

Example 3 with ColorCard

use of it.gmariotti.cardslib.demo.extras.cards.ColorCard in project cardslib by gabrielemariotti.

the class ListViewAnimationsFragment 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++) {
        ColorCard card = new ColorCard(this.getActivity());
        //Only for test scope, use different titles and colors
        card.setTitle("A simple colored card " + i);
        card.setCount(i);
        switch(i % 5) {
            case 0:
                card.setBackgroundResourceId(R.drawable.demoextra_card_selector_color1);
                break;
            case 1:
                card.setBackgroundResourceId(R.drawable.demoextra_card_selector_color2);
                break;
            case 2:
                card.setBackgroundResourceId(R.drawable.demoextra_card_selector_color3);
                break;
            case 3:
                card.setBackgroundResourceId(R.drawable.demoextra_card_selector_color4);
                break;
            case 4:
                card.setBackgroundResourceId(R.drawable.demoextra_card_selector_color5);
                break;
        }
        cards.add(card);
    }
    //Set the adapter
    mCardArrayAdapter = new CardArrayAdapter(getActivity(), cards);
    mListView = (CardListView) getActivity().findViewById(R.id.carddemo_extra_list_viewanimations);
    if (mListView != null) {
        setAlphaAdapter();
    }
}
Also used : ArrayList(java.util.ArrayList) CardArrayAdapter(it.gmariotti.cardslib.library.internal.CardArrayAdapter) ColorCard(it.gmariotti.cardslib.demo.extras.cards.ColorCard) Card(it.gmariotti.cardslib.library.internal.Card) ColorCard(it.gmariotti.cardslib.demo.extras.cards.ColorCard)

Aggregations

ColorCard (it.gmariotti.cardslib.demo.extras.cards.ColorCard)3 Card (it.gmariotti.cardslib.library.internal.Card)3 CardArrayAdapter (it.gmariotti.cardslib.library.internal.CardArrayAdapter)2 ArrayList (java.util.ArrayList)2 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 CardListView (it.gmariotti.cardslib.library.view.CardListView)1 CardViewWrapper (it.gmariotti.cardslib.library.view.base.CardViewWrapper)1