Search in sources :

Example 26 with CardView

use of it.gmariotti.cardslib.library.view.CardView in project cardslib by gabrielemariotti.

the class HeaderFragment method init_header_with_custom_inner_layout.

/**
     * This method builds a header with custom inner layout
     */
private void init_header_with_custom_inner_layout() {
    //Create a Card
    Card card = new Card(getActivity());
    //Create a CardHeader
    CustomHeaderInnerCard header = new CustomHeaderInnerCard(getActivity());
    //Add Header to card
    card.addCardHeader(header);
    //Set card in the CardView
    CardView cardView = (CardView) getActivity().findViewById(R.id.carddemo_header_inner);
    cardView.setCard(card);
}
Also used : 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) CustomHeaderInnerCard(it.gmariotti.cardslib.demo.cards.CustomHeaderInnerCard)

Example 27 with CardView

use of it.gmariotti.cardslib.library.view.CardView in project cardslib by gabrielemariotti.

the class HeaderFragment method init_standard_header_with_overflow_button_dynamic_menu.

/**
     * This method builds a standard header with overflow button with a dynamic menu
     */
private void init_standard_header_with_overflow_button_dynamic_menu() {
    //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();
        }
    });
    //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_dynamic);
    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 28 with CardView

use of it.gmariotti.cardslib.library.view.CardView in project cardslib by gabrielemariotti.

the class HeaderFragment 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 CardView
    CardView cardView = (CardView) getActivity().findViewById(R.id.carddemo_header_std);
    cardView.setCard(card);
}
Also used : 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 29 with CardView

use of it.gmariotti.cardslib.library.view.CardView in project cardslib by gabrielemariotti.

the class HeaderFragment 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_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
            card.getCardHeader().setOtherButtonDrawable(R.drawable.card_menu_button_other_add);
            card.getCardView().refreshCard(card);
        }
    });
    card.addCardHeader(header);
    //Set card in the CardView
    CardView cardView = (CardView) getActivity().findViewById(R.id.carddemo_header_buttonleft);
    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 CardView

use of it.gmariotti.cardslib.library.view.CardView 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

CardView (it.gmariotti.cardslib.library.view.CardView)40 Card (it.gmariotti.cardslib.library.internal.Card)31 CardHeader (it.gmariotti.cardslib.library.internal.CardHeader)20 CustomCard (it.gmariotti.cardslib.demo.cards.CustomCard)12 CustomExpandCard (it.gmariotti.cardslib.demo.cards.CustomExpandCard)11 CustomHeaderInnerCard (it.gmariotti.cardslib.demo.cards.CustomHeaderInnerCard)11 BaseCard (it.gmariotti.cardslib.library.internal.base.BaseCard)11 View (android.view.View)9 ScrollView (android.widget.ScrollView)7 CardExpand (it.gmariotti.cardslib.library.internal.CardExpand)6 TextView (android.widget.TextView)4 CustomThumbCard (it.gmariotti.cardslib.demo.cards.CustomThumbCard)4 CardThumbnail (it.gmariotti.cardslib.library.internal.CardThumbnail)4 MenuItem (android.view.MenuItem)3 ViewToClickToExpand (it.gmariotti.cardslib.library.internal.ViewToClickToExpand)3 LayoutInflater (android.view.LayoutInflater)2 PopupMenu (android.widget.PopupMenu)2 Crouton (de.keyboardsurfer.android.widget.crouton.Crouton)2 GoogleNowBirthCard (it.gmariotti.cardslib.demo.cards.GoogleNowBirthCard)2 MayKnowCard (it.gmariotti.cardslib.demo.cards.MayKnowCard)2