Search in sources :

Example 26 with CardHeader

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

the class HeaderFragment method init_standard_header_with_expandcollapse_button.

/**
 * This method builds a standard header with base expand/collpase
 */
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_basetitle));
    card.addCardExpand(expand);
    // Set card in the CardView
    CardView cardView = (CardView) getActivity().findViewById(R.id.carddemo_header_expand);
    cardView.setCard(card);
}
Also used : CardExpand(it.gmariotti.cardslib.library.internal.CardExpand) CardHeader(it.gmariotti.cardslib.library.internal.CardHeader) 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 27 with CardHeader

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

the class HeaderFragment method init_standard_header_with_overflow_button.

/**
 * This method builds a standard header with overflow button
 */
private void init_standard_header_with_overflow_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));
    // 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);
    // Set card in the CardView
    CardView CardView = (CardView) getActivity().findViewById(R.id.carddemo_header_overflow);
    CardView.setCard(card);
}
Also used : BaseCard(it.gmariotti.cardslib.library.internal.base.BaseCard) CardHeader(it.gmariotti.cardslib.library.internal.CardHeader) CardView(it.gmariotti.cardslib.library.view.CardView) MenuItem(android.view.MenuItem) 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 28 with CardHeader

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

the class HeaderFragment method init_standard_header_with_overflow_button_dynamic_menu_without_xml.

/**
 * This method builds a standard header with overflow button with a dynamic menu
 */
private void init_standard_header_with_overflow_button_dynamic_menu_without_xml() {
    // 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));
    // Add a popup menu. This method set OverFlow button to visible
    header.setButtonOverflowVisible(true);
    header.setPopupMenuListener(new CardHeader.OnClickCardHeaderPopupMenuListener() {

        @Override
        public void onMenuItemClick(BaseCard card, MenuItem item) {
            Toast.makeText(getActivity(), "Click on " + item.getTitle() + "-" + ((Card) card).getCardHeader().getTitle(), Toast.LENGTH_SHORT).show();
        }
    });
    // Add a PopupMenuPrepareListener to add dynamically a menu entry
    // it is optional.
    header.setPopupMenuPrepareListener(new CardHeader.OnPrepareCardHeaderPopupMenuListener() {

        @Override
        public boolean onPreparePopupMenu(BaseCard card, PopupMenu popupMenu) {
            popupMenu.getMenu().add("Dynamic item");
            return true;
        }
    });
    card.addCardHeader(header);
    // Set card in the CardView
    CardView cardView = (CardView) getActivity().findViewById(R.id.carddemo_header_overflow_dynamic2);
    cardView.setCard(card);
}
Also used : BaseCard(it.gmariotti.cardslib.library.internal.base.BaseCard) CardHeader(it.gmariotti.cardslib.library.internal.CardHeader) CardView(it.gmariotti.cardslib.library.view.CardView) MenuItem(android.view.MenuItem) 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) PopupMenu(android.widget.PopupMenu)

Example 29 with CardHeader

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

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

the class HeaderFragment 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 CardView
    final CardView cardView = (CardView) getActivity().findViewById(R.id.carddemo_header_other_button);
    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)

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