Search in sources :

Example 6 with CardHeader

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

the class NativeHeaderFragment method init_standard_header_with_custom_other_button.

/**
 * This method builds a standard header with other button visible
 */
private void init_standard_header_with_custom_other_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.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();
        }
    });
    // Add Header to card
    card.addCardHeader(header);
    // Set card in the CardViewNative
    final CardViewNative cardViewNative = (CardViewNative) getActivity().findViewById(R.id.carddemo_header_other_button);
    cardViewNative.setCard(card);
}
Also used : CardHeader(it.gmariotti.cardslib.library.internal.CardHeader) ScrollView(android.widget.ScrollView) View(android.view.View) 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 7 with CardHeader

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

the class NativeHeaderFragment method init_header_buttonleft.

/**
 * This method builds a header with full custom layout, with buttons on the left
 */
private void init_header_buttonleft() {
    // Create a Card
    Card card = new Card(getActivity());
    // Create a CardHeader
    CardHeader header = new CardHeader(getActivity(), R.layout.carddemo_native_buttonleft_inner_header);
    // Set the header title
    header.setTitle(getString(R.string.demo_header_basetitle));
    header.setOtherButtonVisible(true);
    header.setOtherButtonClickListener(new CardHeader.OnClickCardHeaderOtherButtonListener() {

        @Override
        public void onButtonItemClick(Card card, View view) {
            // Example to change dinamically the button resources
            if (Build.VERSION.SDK_INT >= Constants.API_L) {
                card.getCardHeader().setOtherButtonDrawable(R.drawable.ic_action_add);
            } else {
                card.getCardHeader().setOtherButtonDrawable(R.drawable.card_menu_button_other_add);
            }
            card.getCardView().refreshCard(card);
        }
    });
    card.addCardHeader(header);
    // Set card in the CardViewNative
    CardViewNative cardViewNative = (CardViewNative) getActivity().findViewById(R.id.carddemo_header_buttonleft);
    cardViewNative.setCard(card);
}
Also used : CardHeader(it.gmariotti.cardslib.library.internal.CardHeader) ScrollView(android.widget.ScrollView) View(android.view.View) 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 8 with CardHeader

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

the class NativeHeaderFragment method init_standard_header_without_buttons.

/**
 * This method builds a standard header without buttons
 */
private void init_standard_header_without_buttons() {
    // 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));
    card.addCardHeader(header);
    // Set card in the CardViewNative
    CardViewNative cardView = (CardViewNative) getActivity().findViewById(R.id.carddemo_header_std);
    cardView.setCard(card);
}
Also used : CardHeader(it.gmariotti.cardslib.library.internal.CardHeader) 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 9 with CardHeader

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

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

the class NativeHeaderFragment 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
    if (Build.VERSION.SDK_INT >= Constants.API_L) {
        // Use the simple png. It is the src in image (Android-L uses the ripple)
        header.setOtherButtonDrawable(R.drawable.ic_action_add);
    } else {
        // Use a selector. It is the background in image
        header.setOtherButtonDrawable(R.drawable.card_menu_button_other_add);
    }
    // Add Header to card
    card.addCardHeader(header);
    // Set card in the CardViewNative
    final CardViewNative cardViewNative = (CardViewNative) getActivity().findViewById(R.id.carddemo_header_other_button_programmatically);
    cardViewNative.setCard(card);
}
Also used : CardHeader(it.gmariotti.cardslib.library.internal.CardHeader) ScrollView(android.widget.ScrollView) View(android.view.View) 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)

Aggregations

CardHeader (it.gmariotti.cardslib.library.internal.CardHeader)58 Card (it.gmariotti.cardslib.library.internal.Card)51 BaseCard (it.gmariotti.cardslib.library.internal.base.BaseCard)27 CustomExpandCard (it.gmariotti.cardslib.demo.cards.CustomExpandCard)20 CardView (it.gmariotti.cardslib.library.view.CardView)20 CardViewNative (it.gmariotti.cardslib.library.view.CardViewNative)20 View (android.view.View)19 CustomHeaderInnerCard (it.gmariotti.cardslib.demo.cards.CustomHeaderInnerCard)18 MenuItem (android.view.MenuItem)15 CustomCard (it.gmariotti.cardslib.demo.cards.CustomCard)12 ScrollView (android.widget.ScrollView)11 TextView (android.widget.TextView)8 CardExpand (it.gmariotti.cardslib.library.internal.CardExpand)8 CustomThumbCard (it.gmariotti.cardslib.demo.cards.CustomThumbCard)6 CardThumbnail (it.gmariotti.cardslib.library.internal.CardThumbnail)6 ArrayList (java.util.ArrayList)5 PopupMenu (android.widget.PopupMenu)4 ViewToClickToExpand (it.gmariotti.cardslib.library.internal.ViewToClickToExpand)4 CardListView (it.gmariotti.cardslib.library.view.CardListView)4 ViewGroup (android.view.ViewGroup)2