Search in sources :

Example 6 with CardExpand

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

the class NativeFabFragment 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++) {
        Card card = new Card(this.getActivity());
        card.setTitle("Application example " + i);
        //Create a CardHeader
        CardHeader header = new CardHeader(getActivity());
        //Set the header title
        header.setTitle(getString(R.string.demo_header_basetitle));
        if (i < 10) {
            //Add a popup menu. This method set OverFlow button to visible
            header.setPopupMenu(R.menu.popupmain, new CardHeader.OnClickCardHeaderPopupMenuListener() {

                @Override
                public void onMenuItemClick(BaseCard card, MenuItem item) {
                    Toast.makeText(getActivity(), "Click on " + item.getTitle(), Toast.LENGTH_SHORT).show();
                }
            });
            card.addCardHeader(header);
        } else {
            //Set visible the expand/collapse button
            header.setButtonExpandVisible(true);
            card.addCardHeader(header);
            //This provides a simple (and useless) expand area
            CardExpand expand = new CardExpand(getActivity());
            //Set inner title in Expand Area
            expand.setTitle(getString(R.string.demo_expand_basetitle));
            card.addCardExpand(expand);
            if (i == 12 || i == 17 || i == 19)
                card.setExpanded(true);
        }
        //Add ClickListener
        card.setOnClickListener(new Card.OnCardClickListener() {

            @Override
            public void onClick(Card card, View view) {
                Toast.makeText(getActivity(), "Click Listener card=" + card.getTitle(), Toast.LENGTH_SHORT).show();
            }
        });
        cards.add(card);
    }
    return cards;
}
Also used : CardExpand(it.gmariotti.cardslib.library.internal.CardExpand) BaseCard(it.gmariotti.cardslib.library.internal.base.BaseCard) ArrayList(java.util.ArrayList) CardHeader(it.gmariotti.cardslib.library.internal.CardHeader) MenuItem(android.view.MenuItem) CardListView(it.gmariotti.cardslib.library.view.CardListView) View(android.view.View) BaseCard(it.gmariotti.cardslib.library.internal.base.BaseCard) Card(it.gmariotti.cardslib.library.internal.Card)

Example 7 with CardExpand

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

the class NativeCardExpandFragment method init_custom_card_expand.

/**
     * This method builds a custom card with expand/collapse action clickable in all card view
     */
private void init_custom_card_expand() {
    //Create a Card
    CustomCard card = new CustomCard(getActivity());
    //This provides a simple (and useless) expand area
    CardExpand expand = new CardExpand(getActivity());
    //Set inner title in Expand Area
    expand.setTitle(getString(R.string.demo_expand_customtitle3));
    card.addCardExpand(expand);
    //Set card in the cardView
    CardViewNative cardView = (CardViewNative) getActivity().findViewById(R.id.carddemo_example_card_expand2);
    ViewToClickToExpand viewToClickToExpand = ViewToClickToExpand.builder().setupView(cardView);
    card.setViewToClickToExpand(viewToClickToExpand);
    cardView.setCard(card);
}
Also used : ViewToClickToExpand(it.gmariotti.cardslib.library.internal.ViewToClickToExpand) CustomCard(it.gmariotti.cardslib.demo.cards.CustomCard) CardExpand(it.gmariotti.cardslib.library.internal.CardExpand) CardViewNative(it.gmariotti.cardslib.library.view.CardViewNative)

Example 8 with CardExpand

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

the class NativeCardExpandFragment method init_custom_card_expand_clicking_image.

/**
     * This method builds a custom card with expand/collapse action clickable in all card view
     */
private void init_custom_card_expand_clicking_image() {
    //Create a Card
    Card card = new Card(getActivity());
    //This provides a simple (and useless) expand area
    CardExpand expand = new CardExpand(getActivity());
    //Set inner title in Expand Area
    expand.setTitle(getString(R.string.demo_expand_customtitle3));
    card.addCardExpand(expand);
    CustomThumbnail thumb = new CustomThumbnail(getActivity());
    thumb.setDrawableResource(R.drawable.ic_smile);
    card.addCardThumbnail(thumb);
    //Set card in the cardView
    CardViewNative cardView = (CardViewNative) getActivity().findViewById(R.id.carddemo_example_card_expand4);
    cardView.setCard(card);
}
Also used : CardExpand(it.gmariotti.cardslib.library.internal.CardExpand) Card(it.gmariotti.cardslib.library.internal.Card) CustomCard(it.gmariotti.cardslib.demo.cards.CustomCard) CardViewNative(it.gmariotti.cardslib.library.view.CardViewNative)

Example 9 with CardExpand

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

the class NativeCardExpandFragment method init_standard_header_with_expandcollapse_button.

/**
     * This method builds a standard header with base expand/collapse
     */
private void init_standard_header_with_expandcollapse_button() {
    //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.setButtonExpandVisible(true);
    //Add Header to card
    card.addCardHeader(header);
    //This provides a simple (and useless) expand area
    CardExpand expand = new CardExpand(getActivity());
    //Set inner title in Expand Area
    expand.setTitle(getString(R.string.demo_expand_customtitle3));
    card.addCardExpand(expand);
    //Set card in the cardView
    CardViewNative cardView = (CardViewNative) getActivity().findViewById(R.id.carddemo_example_card_expand1);
    cardView.setCard(card);
}
Also used : CardExpand(it.gmariotti.cardslib.library.internal.CardExpand) CardHeader(it.gmariotti.cardslib.library.internal.CardHeader) Card(it.gmariotti.cardslib.library.internal.Card) CustomCard(it.gmariotti.cardslib.demo.cards.CustomCard) CardViewNative(it.gmariotti.cardslib.library.view.CardViewNative)

Example 10 with CardExpand

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

the class NativeCardExpandFragment method init_custom_card_expand_programmatic.

/**
     * This method builds a card with a collpse/expand action in programmatic way
     */
private void init_custom_card_expand_programmatic() {
    //Create a Card
    final Card card = new Card(getActivity());
    //This provides a simple (and useless) expand area
    CardExpand expand = new CardExpand(getActivity());
    //Set inner title in Expand Area
    expand.setTitle(getString(R.string.demo_expand_customtitle3));
    card.addCardExpand(expand);
    ViewToClickToExpand viewToClickToExpand = ViewToClickToExpand.builder().enableForExpandAction();
    card.setViewToClickToExpand(viewToClickToExpand);
    TextView tx = (TextView) getActivity().findViewById(R.id.carddemo_example_card_expand6_text);
    tx.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            card.doToogleExpand();
        }
    });
    //Set card in the cardView
    CardViewNative cardView = (CardViewNative) getActivity().findViewById(R.id.carddemo_example_card_expand6);
    cardView.setCard(card);
}
Also used : ViewToClickToExpand(it.gmariotti.cardslib.library.internal.ViewToClickToExpand) CardExpand(it.gmariotti.cardslib.library.internal.CardExpand) TextView(android.widget.TextView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) View(android.view.View) Card(it.gmariotti.cardslib.library.internal.Card) CustomCard(it.gmariotti.cardslib.demo.cards.CustomCard) CardViewNative(it.gmariotti.cardslib.library.view.CardViewNative)

Aggregations

CardExpand (it.gmariotti.cardslib.library.internal.CardExpand)18 Card (it.gmariotti.cardslib.library.internal.Card)14 View (android.view.View)8 CustomCard (it.gmariotti.cardslib.demo.cards.CustomCard)8 CardHeader (it.gmariotti.cardslib.library.internal.CardHeader)8 CardView (it.gmariotti.cardslib.library.view.CardView)6 CardViewNative (it.gmariotti.cardslib.library.view.CardViewNative)6 TextView (android.widget.TextView)5 BaseCard (it.gmariotti.cardslib.library.internal.base.BaseCard)5 ViewToClickToExpand (it.gmariotti.cardslib.library.internal.ViewToClickToExpand)4 MenuItem (android.view.MenuItem)3 ImageView (android.widget.ImageView)3 ArrayList (java.util.ArrayList)3 ScrollView (android.widget.ScrollView)2 CustomExpandCard (it.gmariotti.cardslib.demo.cards.CustomExpandCard)2 CustomHeaderInnerCard (it.gmariotti.cardslib.demo.cards.CustomHeaderInnerCard)2 CardRecyclerView (it.gmariotti.cardslib.library.recyclerview.view.CardRecyclerView)2 CardListView (it.gmariotti.cardslib.library.view.CardListView)1