Search in sources :

Example 1 with ColorCard

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

the class ListColorFragment method initCards.

private void initCards() {
    //Init an array of Cards
    ArrayList<Card> cards = new ArrayList<Card>();
    for (int i = 0; i < 5; i++) {
        ColorCard card = new ColorCard(this.getActivity());
        card.setTitle("A simple colored card " + i);
        card.setCount(i);
        switch(i) {
            case 0:
                card.setBackgroundResourceId(R.drawable.demo_card_selector_color5);
                break;
            case 1:
                card.setBackgroundResourceId(R.drawable.demo_card_selector_color4);
                break;
            case 2:
                card.setBackgroundResourceId(R.drawable.demo_card_selector_color3);
                break;
            case 3:
                card.setBackgroundResourceId(R.drawable.demo_card_selector_color2);
                break;
            case 4:
                card.setBackgroundResourceId(R.drawable.demo_card_selector_color1);
                break;
        }
        cards.add(card);
    }
    CardArrayAdapter mCardArrayAdapter = new CardArrayAdapter(getActivity(), cards);
    CardListView listView = (CardListView) getActivity().findViewById(R.id.carddemo_list_colors);
    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) ColorCard(it.gmariotti.cardslib.demo.cards.ColorCard) Card(it.gmariotti.cardslib.library.internal.Card) ColorCard(it.gmariotti.cardslib.demo.cards.ColorCard)

Example 2 with ColorCard

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

the class NativeChangeValueCardFragment method initCards.

/**
     * Inits the initial card
     */
private void initCards() {
    card1 = new CardExample(getActivity(), "Header", "Title");
    cardView1 = (CardViewNative) getActivity().findViewById(R.id.carddemo_card_changevalue_id);
    cardView1.setCard(card1);
    card2 = new CardExample2(getActivity(), "Header", "Title");
    cardView2 = (CardViewNative) getActivity().findViewById(R.id.carddemo_card_changevalue_id2);
    cardView2.setCard(card2);
    card3 = new CardExample3(getActivity(), "Header", "Title");
    cardView3 = (CardViewNative) getActivity().findViewById(R.id.carddemo_card_changevalue_id3);
    cardView3.setCard(card3);
    card4 = new ColorCard(getActivity());
    card4.setTitle("A simple car");
    cardView4 = (CardViewNative) getActivity().findViewById(R.id.carddemo_card_changevalue_id4);
    StateListDrawable initDrawable = new StateListDrawable();
    initDrawable.addState(new int[] { android.R.attr.state_pressed }, getResources().getDrawable(R.drawable.pressed_background_card));
    initDrawable.addState(new int[] {}, getResources().getDrawable(R.drawable.demo_card_background_color1));
    card4.setBackgroundResource(initDrawable);
    cardView4.setCard(card4);
}
Also used : StateListDrawable(android.graphics.drawable.StateListDrawable) ColorCard(it.gmariotti.cardslib.demo.cards.ColorCard)

Example 3 with ColorCard

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

the class NativeListColorFragment method initCards.

private void initCards() {
    //Init an array of Cards
    ArrayList<Card> cards = new ArrayList<Card>();
    for (int i = 0; i < 5; i++) {
        ColorCard card = new ColorCard(this.getActivity());
        card.setTitle("A simple colored card " + i);
        card.setCount(i);
        switch(i) {
            case 0:
                card.setBackgroundColorResourceId(R.color.demo_card_background_color5);
                break;
            case 1:
                card.setBackgroundColorResourceId(R.color.demo_card_background_color4);
                break;
            case 2:
                card.setBackgroundColorResourceId(R.color.demo_card_background_color3);
                break;
            case 3:
                card.setBackgroundColorResourceId(R.color.demo_card_background_color2);
                break;
            case 4:
                card.setBackgroundColorResourceId(R.color.demo_card_background_color1);
                break;
        }
        cards.add(card);
    }
    CardArrayAdapter mCardArrayAdapter = new CardArrayAdapter(getActivity(), cards);
    CardListView listView = (CardListView) getActivity().findViewById(R.id.carddemo_list_colors);
    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) ColorCard(it.gmariotti.cardslib.demo.cards.ColorCard) Card(it.gmariotti.cardslib.library.internal.Card) ColorCard(it.gmariotti.cardslib.demo.cards.ColorCard)

Example 4 with ColorCard

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

the class ChangeValueCardFragment method initCards.

/**
     * Inits the initial card
     */
private void initCards() {
    card1 = new CardExample(getActivity(), "Header", "Title");
    cardView1 = (CardView) getActivity().findViewById(R.id.carddemo_card_changevalue_id);
    cardView1.setCard(card1);
    card2 = new CardExample2(getActivity(), "Header", "Title");
    cardView2 = (CardView) getActivity().findViewById(R.id.carddemo_card_changevalue_id2);
    cardView2.setCard(card2);
    card3 = new CardExample3(getActivity(), "Header", "Title");
    cardView3 = (CardView) getActivity().findViewById(R.id.carddemo_card_changevalue_id3);
    cardView3.setCard(card3);
    card4 = new ColorCard(getActivity());
    card4.setTitle("A simple car");
    cardView4 = (CardView) getActivity().findViewById(R.id.carddemo_card_changevalue_id4);
    StateListDrawable initDrawable = new StateListDrawable();
    initDrawable.addState(new int[] { android.R.attr.state_pressed }, getResources().getDrawable(R.drawable.pressed_background_card));
    initDrawable.addState(new int[] {}, getResources().getDrawable(R.drawable.demo_card_background_color1));
    card4.setBackgroundResource(initDrawable);
    cardView4.setCard(card4);
}
Also used : StateListDrawable(android.graphics.drawable.StateListDrawable) ColorCard(it.gmariotti.cardslib.demo.cards.ColorCard)

Aggregations

ColorCard (it.gmariotti.cardslib.demo.cards.ColorCard)4 StateListDrawable (android.graphics.drawable.StateListDrawable)2 Card (it.gmariotti.cardslib.library.internal.Card)2 CardArrayAdapter (it.gmariotti.cardslib.library.internal.CardArrayAdapter)2 CardListView (it.gmariotti.cardslib.library.view.CardListView)2 ArrayList (java.util.ArrayList)2