Search in sources :

Example 21 with Card

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

the class HeaderFragment method init_standard_header_with_custom_other_button_programmatically.

/**
     * This method builds a standard header with other button visible which drawable is defined programmatically
     */
private void init_standard_header_with_custom_other_button_programmatically() {
    //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));
    //Set visible the expand/collapse button
    header.setOtherButtonVisible(true);
    //Add a callback
    header.setOtherButtonClickListener(new CardHeader.OnClickCardHeaderOtherButtonListener() {

        @Override
        public void onButtonItemClick(Card card, View view) {
            Toast.makeText(getActivity(), "Click on Other Button", Toast.LENGTH_LONG).show();
        }
    });
    //Use this code to set your drawable
    header.setOtherButtonDrawable(R.drawable.card_menu_button_other_add);
    //Add Header to card
    card.addCardHeader(header);
    //Set card in the CardView
    final CardView cardView = (CardView) getActivity().findViewById(R.id.carddemo_header_other_button_programmatically);
    cardView.setCard(card);
}
Also used : CardHeader(it.gmariotti.cardslib.library.internal.CardHeader) CardView(it.gmariotti.cardslib.library.view.CardView) ScrollView(android.widget.ScrollView) View(android.view.View) CardView(it.gmariotti.cardslib.library.view.CardView) BaseCard(it.gmariotti.cardslib.library.internal.base.BaseCard) CustomExpandCard(it.gmariotti.cardslib.demo.cards.CustomExpandCard) CustomHeaderInnerCard(it.gmariotti.cardslib.demo.cards.CustomHeaderInnerCard) Card(it.gmariotti.cardslib.library.internal.Card)

Example 22 with Card

use of it.gmariotti.cardslib.library.internal.Card 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 23 with Card

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

the class ListExpandCardFragment method initCards.

private void initCards() {
    //Init an array of Cards
    ArrayList<Card> cards = new ArrayList<Card>();
    for (int i = 0; i < 200; i++) {
        Card card = init_standard_header_with_expandcollapse_button_custom_area("Header " + i, i);
        cards.add(card);
    }
    CardArrayAdapter mCardArrayAdapter = new CardArrayAdapter(getActivity(), cards);
    CardListView listView = (CardListView) getActivity().findViewById(R.id.carddemo_list_expand);
    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) CustomExpandCard(it.gmariotti.cardslib.demo.cards.CustomExpandCard) Card(it.gmariotti.cardslib.library.internal.Card)

Example 24 with Card

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

the class ListGplayCardFragment method initCards.

private void initCards() {
    //Init an array of Cards
    ArrayList<Card> cards = new ArrayList<Card>();
    for (int i = 0; i < 200; i++) {
        GooglePlaySmallCard card = new GooglePlaySmallCard(this.getActivity());
        card.setTitle("Application example " + i);
        card.setSecondaryTitle("A company inc..." + i);
        card.setRating((float) (Math.random() * (5.0)));
        card.count = i;
        //Only for test, change some icons
        if ((i > 10 && i < 15) || (i > 35 && i < 45)) {
            card.setResourceIdThumbnail(R.drawable.ic_launcher);
        }
        card.init();
        cards.add(card);
    }
    CardArrayAdapter mCardArrayAdapter = new CardArrayAdapter(getActivity(), cards);
    CardListView listView = (CardListView) getActivity().findViewById(R.id.carddemo_list_gplaycard);
    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) Card(it.gmariotti.cardslib.library.internal.Card)

Example 25 with Card

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

the class CardFragment method init_custom_card.

/**
     * This method builds a custom card
     */
private void init_custom_card() {
    //Create a Card
    Card card = new CustomCard(getActivity());
    //Set card in the cardView
    CardView cardView = (CardView) getActivity().findViewById(R.id.carddemo_example_card3);
    cardView.setCard(card);
}
Also used : CustomCard(it.gmariotti.cardslib.demo.cards.CustomCard) CardView(it.gmariotti.cardslib.library.view.CardView) Card(it.gmariotti.cardslib.library.internal.Card) CustomCard(it.gmariotti.cardslib.demo.cards.CustomCard)

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