Search in sources :

Example 41 with Card

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

the class NativeGridGplayFragment method initCards.

private void initCards() {
    ArrayList<Card> cards = new ArrayList<Card>();
    for (int i = 0; i < 200; i++) {
        GplayGridCard card = new GplayGridCard(getActivity());
        card.headerTitle = "App example " + i;
        card.secondaryTitle = "Some text here " + i;
        card.rating = (float) (Math.random() * (5.0));
        //Only for test, change some icons
        if ((i % 6 == 0)) {
            card.resourceIdThumbnail = R.drawable.ic_ic_dh_bat;
        } else if ((i % 6 == 1)) {
            card.resourceIdThumbnail = R.drawable.ic_ic_dh_net;
        } else if ((i % 6 == 2)) {
            card.resourceIdThumbnail = R.drawable.ic_tris;
        } else if ((i % 6 == 3)) {
            card.resourceIdThumbnail = R.drawable.ic_info;
        } else if ((i % 6 == 4)) {
            card.resourceIdThumbnail = R.drawable.ic_smile;
        }
        card.init();
        cards.add(card);
    }
    CardGridArrayAdapter mCardArrayAdapter = new CardGridArrayAdapter(getActivity(), cards);
    CardGridView listView = (CardGridView) getActivity().findViewById(R.id.carddemo_grid_base1);
    if (listView != null) {
        listView.setAdapter(mCardArrayAdapter);
    }
}
Also used : ArrayList(java.util.ArrayList) CardGridArrayAdapter(it.gmariotti.cardslib.library.internal.CardGridArrayAdapter) CardGridView(it.gmariotti.cardslib.library.view.CardGridView) BaseCard(it.gmariotti.cardslib.library.internal.base.BaseCard) Card(it.gmariotti.cardslib.library.internal.Card)

Example 42 with Card

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

use of it.gmariotti.cardslib.library.internal.Card 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)

Example 44 with Card

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

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

the class NativeHeaderFragment 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 CardViewNative
    CardViewNative cardViewNative = (CardViewNative) getActivity().findViewById(R.id.carddemo_header_overflow);
    cardViewNative.setCard(card);
}
Also used : BaseCard(it.gmariotti.cardslib.library.internal.base.BaseCard) CardHeader(it.gmariotti.cardslib.library.internal.CardHeader) 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) CardViewNative(it.gmariotti.cardslib.library.view.CardViewNative)

Aggregations

Card (it.gmariotti.cardslib.library.internal.Card)134 ArrayList (java.util.ArrayList)53 CardHeader (it.gmariotti.cardslib.library.internal.CardHeader)51 BaseCard (it.gmariotti.cardslib.library.internal.base.BaseCard)39 View (android.view.View)35 CardView (it.gmariotti.cardslib.library.view.CardView)31 CardViewNative (it.gmariotti.cardslib.library.view.CardViewNative)31 CustomExpandCard (it.gmariotti.cardslib.demo.cards.CustomExpandCard)26 CardArrayAdapter (it.gmariotti.cardslib.library.internal.CardArrayAdapter)26 CardListView (it.gmariotti.cardslib.library.view.CardListView)24 CustomCard (it.gmariotti.cardslib.demo.cards.CustomCard)22 CustomHeaderInnerCard (it.gmariotti.cardslib.demo.cards.CustomHeaderInnerCard)22 ScrollView (android.widget.ScrollView)15 TextView (android.widget.TextView)14 CardExpand (it.gmariotti.cardslib.library.internal.CardExpand)14 MenuItem (android.view.MenuItem)10 CardThumbnail (it.gmariotti.cardslib.library.internal.CardThumbnail)9 CustomThumbCard (it.gmariotti.cardslib.demo.cards.CustomThumbCard)8 PicassoCard (it.gmariotti.cardslib.demo.extras.cards.PicassoCard)7 CardRecyclerView (it.gmariotti.cardslib.library.recyclerview.view.CardRecyclerView)7