Search in sources :

Example 1 with CustomExpandCard

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

the class NativeListExpandCardFragment method init_standard_header_with_expandcollapse_button_custom_area.

/**
 * This method builds a standard header with a custom expand/collpase
 */
private Card init_standard_header_with_expandcollapse_button_custom_area(String titleHeader, int i) {
    // Create a Card
    Card card = new Card(getActivity());
    // Create a CardHeader
    CardHeader header = new CardHeader(getActivity());
    // Set the header title
    header.setTitle(titleHeader);
    // Set visible the expand/collapse button
    header.setButtonExpandVisible(true);
    // Add Header to card
    card.addCardHeader(header);
    // This provides a simple (and useless) expand area
    CustomExpandCard expand = new CustomExpandCard(getActivity(), i);
    // Add Expand Area to Card
    card.addCardExpand(expand);
    // Just an example to expand a card
    if (i == 2 || i == 7 || i == 9)
        card.setExpanded(true);
    // Swipe
    card.setSwipeable(true);
    // Animator listener
    card.setOnExpandAnimatorEndListener(new Card.OnExpandAnimatorEndListener() {

        @Override
        public void onExpandEnd(Card card) {
            Toast.makeText(getActivity(), "Expand " + card.getCardHeader().getTitle(), Toast.LENGTH_SHORT).show();
        }
    });
    card.setOnCollapseAnimatorEndListener(new Card.OnCollapseAnimatorEndListener() {

        @Override
        public void onCollapseEnd(Card card) {
            Toast.makeText(getActivity(), "Collpase " + card.getCardHeader().getTitle(), Toast.LENGTH_SHORT).show();
        }
    });
    return card;
}
Also used : CardHeader(it.gmariotti.cardslib.library.internal.CardHeader) CustomExpandCard(it.gmariotti.cardslib.demo.cards.CustomExpandCard) CustomExpandCard(it.gmariotti.cardslib.demo.cards.CustomExpandCard) Card(it.gmariotti.cardslib.library.internal.Card)

Example 2 with CustomExpandCard

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

the class NativeHeaderFragment method init_standard_header_with_expandcollapse_button_custom_area.

/**
 * This method builds a standard header with a custom expand/collpase
 */
private void init_standard_header_with_expandcollapse_button_custom_area() {
    // 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
    CustomExpandCard expand = new CustomExpandCard(getActivity());
    // Add Expand Area to Card
    card.addCardExpand(expand);
    // Set card in the CardViewNative
    final CardViewNative cardViewNative = (CardViewNative) getActivity().findViewById(R.id.carddemo_header_expand_custom_area);
    // It is not required.
    card.setOnExpandAnimatorEndListener(new Card.OnExpandAnimatorEndListener() {

        @Override
        public void onExpandEnd(Card card) {
        // TODO: check if hidden area is visible and it would be better an animator to do this
        }
    });
    cardViewNative.setCard(card);
}
Also used : CardHeader(it.gmariotti.cardslib.library.internal.CardHeader) CustomExpandCard(it.gmariotti.cardslib.demo.cards.CustomExpandCard) 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) CardViewNative(it.gmariotti.cardslib.library.view.CardViewNative)

Example 3 with CustomExpandCard

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

the class ListExpandCardFragment method init_standard_header_with_expandcollapse_button_custom_area.

/**
 * This method builds a standard header with a custom expand/collpase
 */
private Card init_standard_header_with_expandcollapse_button_custom_area(String titleHeader, int i) {
    // Create a Card
    Card card = new Card(getActivity());
    // Create a CardHeader
    CardHeader header = new CardHeader(getActivity());
    // Set the header title
    header.setTitle(titleHeader);
    // Set visible the expand/collapse button
    header.setButtonExpandVisible(true);
    // Add Header to card
    card.addCardHeader(header);
    // This provides a simple (and useless) expand area
    CustomExpandCard expand = new CustomExpandCard(getActivity(), i);
    // Add Expand Area to Card
    card.addCardExpand(expand);
    // Just an example to expand a card
    if (i == 2 || i == 7 || i == 9)
        card.setExpanded(true);
    // Swipe
    card.setSwipeable(true);
    // Animator listener
    card.setOnExpandAnimatorEndListener(new Card.OnExpandAnimatorEndListener() {

        @Override
        public void onExpandEnd(Card card) {
            Toast.makeText(getActivity(), "Expand " + card.getCardHeader().getTitle(), Toast.LENGTH_SHORT).show();
        }
    });
    card.setOnCollapseAnimatorEndListener(new Card.OnCollapseAnimatorEndListener() {

        @Override
        public void onCollapseEnd(Card card) {
            Toast.makeText(getActivity(), "Collpase " + card.getCardHeader().getTitle(), Toast.LENGTH_SHORT).show();
        }
    });
    return card;
}
Also used : CardHeader(it.gmariotti.cardslib.library.internal.CardHeader) CustomExpandCard(it.gmariotti.cardslib.demo.cards.CustomExpandCard) CustomExpandCard(it.gmariotti.cardslib.demo.cards.CustomExpandCard) Card(it.gmariotti.cardslib.library.internal.Card)

Example 4 with CustomExpandCard

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

the class HeaderFragment method init_standard_header_with_expandcollapse_button_custom_area.

/**
 * This method builds a standard header with a custom expand/collpase
 */
private void init_standard_header_with_expandcollapse_button_custom_area() {
    // 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
    CustomExpandCard expand = new CustomExpandCard(getActivity());
    // Add Expand Area to Card
    card.addCardExpand(expand);
    // Set card in the CardView
    final CardView cardView = (CardView) getActivity().findViewById(R.id.carddemo_header_expand_custom_area);
    // It is not required.
    card.setOnExpandAnimatorEndListener(new Card.OnExpandAnimatorEndListener() {

        @Override
        public void onExpandEnd(Card card) {
        // TODO: check if hidden area is visible and it would be better an animator to do this
        }
    });
    cardView.setCard(card);
}
Also used : CardHeader(it.gmariotti.cardslib.library.internal.CardHeader) CardView(it.gmariotti.cardslib.library.view.CardView) CustomExpandCard(it.gmariotti.cardslib.demo.cards.CustomExpandCard) 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)

Aggregations

CustomExpandCard (it.gmariotti.cardslib.demo.cards.CustomExpandCard)4 Card (it.gmariotti.cardslib.library.internal.Card)4 CardHeader (it.gmariotti.cardslib.library.internal.CardHeader)4 CustomHeaderInnerCard (it.gmariotti.cardslib.demo.cards.CustomHeaderInnerCard)2 BaseCard (it.gmariotti.cardslib.library.internal.base.BaseCard)2 CardView (it.gmariotti.cardslib.library.view.CardView)1 CardViewNative (it.gmariotti.cardslib.library.view.CardViewNative)1