Search in sources :

Example 31 with Card

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

the class StickyCardArrayAdapter method getHeaderView.

@Override
public View getHeaderView(int position, View convertView, ViewGroup viewGroup) {
    // Build your custom HeaderView
    //In this case I will use a Card, but you can use any view
    LayoutInflater mInflater = LayoutInflater.from(getContext());
    View view = mInflater.inflate(R.layout.carddemo_extras_sticky_header, null);
    CardViewWrapper cardView = (CardViewWrapper) view.findViewById(R.id.carddemo_card_sticky_header_id);
    Card card = getItem(position);
    char headerChar = card.getTitle().subSequence(0, 1).charAt(0);
    ColorCard colorCard = new ColorCard(getContext());
    colorCard.setTitle("Header : " + headerChar);
    switch(position / 8) {
        case 0:
            colorCard.setBackgroundResourceId(R.drawable.demoextra_card_selector_color1);
            break;
        case 1:
            colorCard.setBackgroundResourceId(R.drawable.demoextra_card_selector_color2);
            break;
        case 2:
            colorCard.setBackgroundResourceId(R.drawable.demoextra_card_selector_color3);
            break;
        case 3:
            colorCard.setBackgroundResourceId(R.drawable.demoextra_card_selector_color4);
            break;
        case 4:
            colorCard.setBackgroundResourceId(R.drawable.demoextra_card_selector_color5);
            break;
        default:
            colorCard.setBackgroundResourceId(R.drawable.demoextra_card_selector_color1);
            break;
    }
    cardView.setCard(colorCard);
    return view;
}
Also used : LayoutInflater(android.view.LayoutInflater) CardViewWrapper(it.gmariotti.cardslib.library.view.base.CardViewWrapper) CardListView(it.gmariotti.cardslib.library.view.CardListView) View(android.view.View) ColorCard(it.gmariotti.cardslib.demo.extras.cards.ColorCard) Card(it.gmariotti.cardslib.library.internal.Card) ColorCard(it.gmariotti.cardslib.demo.extras.cards.ColorCard)

Example 32 with Card

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

the class AnimateStaggeredGridFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    hideList(false);
    //Set the arrayAdapter
    ArrayList<Card> cards = new ArrayList<Card>();
    mCardArrayAdapter = new CardGridStaggeredArrayAdapter(getActivity(), cards);
    staggeredView = (CardGridStaggeredView) getActivity().findViewById(R.id.carddemo_extras_grid_stag);
    //Load cards
    new LoaderAsyncTask().execute();
    //Set the empty view
    staggeredView.setEmptyView(getActivity().findViewById(android.R.id.empty));
    /**
         * Set adapter with animations
         */
    if (staggeredView != null) {
        setAlphaAdapter();
    }
}
Also used : ArrayList(java.util.ArrayList) CardGridStaggeredArrayAdapter(it.gmariotti.cardslib.library.extra.staggeredgrid.internal.CardGridStaggeredArrayAdapter) Card(it.gmariotti.cardslib.library.internal.Card)

Example 33 with Card

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

the class BaseStaggeredGridFragment method initCard.

/**
     * This method builds a simple list of cards
     */
private void initCard() {
    //Only for test scope, use 6 different header titles
    int[] resTitleId = { R.string.carddemo_extras_title_base_stag1, R.string.carddemo_extras_title_base_stag2, R.string.carddemo_extras_title_base_stag3, R.string.carddemo_extras_title_base_stag4, R.string.carddemo_extras_title_base_stag5, R.string.carddemo_extras_title_base_stag6 };
    //Init an array of Cards
    ArrayList<Card> cards = new ArrayList<Card>();
    for (int i = 0; i < 200; i++) {
        SquareGridCard card = new SquareGridCard(getActivity());
        card.headerTitle = "Card " + i;
        //Only for test scope, use random colors, and random height
        int random = (int) (Math.random() * 6);
        card.mainContent = getString(resTitleId[random]);
        if ((random / 2 % 3 == 0)) {
            card.thumbHeightId = R.dimen.carddemo_extras_basestaggered_height1;
        } else if ((random / 2 % 3 == 1)) {
            card.thumbHeightId = R.dimen.carddemo_extras_basestaggered_height2;
        } else if ((random / 2 % 3 == 2)) {
            card.thumbHeightId = R.dimen.carddemo_extras_basestaggered_height3;
        }
        //Only for test, change background color
        if ((i % 5 == 0)) {
            card.color = R.color.demoextra_card_background_color1;
        } else if ((i % 5 == 1)) {
            card.color = R.color.demoextra_card_background_color2;
        } else if ((i % 5 == 2)) {
            card.color = R.color.demoextra_card_background_color3;
        } else if ((i % 5 == 3)) {
            card.color = R.color.demoextra_card_background_color4;
        } else if ((i % 5 == 4)) {
            card.color = R.color.demoextra_card_background_color5;
        }
        card.init();
        cards.add(card);
    }
    //Set the arrayAdapter
    CardGridStaggeredArrayAdapter mCardArrayAdapter = new CardGridStaggeredArrayAdapter(getActivity(), cards);
    CardGridStaggeredView mGridView = (CardGridStaggeredView) getActivity().findViewById(R.id.carddemo_extras_grid_stag);
    if (mGridView != null) {
        mGridView.setAdapter(mCardArrayAdapter);
    }
}
Also used : ArrayList(java.util.ArrayList) CardGridStaggeredArrayAdapter(it.gmariotti.cardslib.library.extra.staggeredgrid.internal.CardGridStaggeredArrayAdapter) CardGridStaggeredView(it.gmariotti.cardslib.library.extra.staggeredgrid.view.CardGridStaggeredView) BaseCard(it.gmariotti.cardslib.library.internal.base.BaseCard) Card(it.gmariotti.cardslib.library.internal.Card)

Example 34 with Card

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

the class CroutonFragment method crouton2.

/**
     * This method builds another crouton card
     */
private void crouton2() {
    LayoutInflater mInflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = mInflater.inflate(R.layout.carddemo_extras_crouton_card, null);
    //Card View
    CardView cardView = (CardView) view.findViewById(R.id.carddemo_card_crouton_id);
    //Card
    Card card = new Card(getActivity());
    card.setTitle("Crouton Card");
    //Add a CardThumbnail
    CardThumbnail thumb = new CardThumbnail(getActivity());
    thumb.setDrawableResource(R.drawable.ic_action_halt);
    card.addCardThumbnail(thumb);
    cardView.setCard(card);
    //Make the crouton view
    final Crouton crouton;
    crouton = Crouton.make(getActivity(), view);
    crouton.show();
}
Also used : Crouton(de.keyboardsurfer.android.widget.crouton.Crouton) LayoutInflater(android.view.LayoutInflater) CardView(it.gmariotti.cardslib.library.view.CardView) View(android.view.View) CardView(it.gmariotti.cardslib.library.view.CardView) CardThumbnail(it.gmariotti.cardslib.library.internal.CardThumbnail) Card(it.gmariotti.cardslib.library.internal.Card)

Example 35 with Card

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

the class CroutonFragment method crouton1.

/**
     * This method builds a crouton card
     */
private void crouton1() {
    LayoutInflater mInflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = mInflater.inflate(R.layout.carddemo_extras_crouton_card, null);
    //CardView
    CardView cardView = (CardView) view.findViewById(R.id.carddemo_card_crouton_id);
    //Card
    Card card = new Card(getActivity());
    card.setTitle("Crouton Card");
    card.setBackgroundResourceId(R.color.demoextra_card_background_color2);
    //Add a cardThumbnail
    CardThumbnail thumb = new CardThumbnail(getActivity());
    thumb.setDrawableResource(R.drawable.ic_action_bulb);
    card.addCardThumbnail(thumb);
    cardView.setCard(card);
    //Make the crouton view
    final Crouton crouton;
    crouton = Crouton.make(getActivity(), view);
    crouton.show();
}
Also used : Crouton(de.keyboardsurfer.android.widget.crouton.Crouton) LayoutInflater(android.view.LayoutInflater) CardView(it.gmariotti.cardslib.library.view.CardView) View(android.view.View) CardView(it.gmariotti.cardslib.library.view.CardView) CardThumbnail(it.gmariotti.cardslib.library.internal.CardThumbnail) Card(it.gmariotti.cardslib.library.internal.Card)

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