Search in sources :

Example 61 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 62 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 63 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)

Example 64 with Card

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

the class GoogleProgressFragment method initCard.

/**
     * This method builds a simple list of cards
     */
private void initCard() {
    //Init an array of Cards
    ArrayList<Card> cards = new ArrayList<Card>();
    for (int i = 0; i < 20; i++) {
        GoogleProgressBarCard card = new GoogleProgressBarCard(this.getActivity());
        card.setTitle("A simple card loaded with Picasso " + i);
        card.setSecondaryTitle("Simple text..." + i);
        card.setCount(i);
        card.setId("" + i);
        card.setProgressBarViewStubLayoutId(R.layout.carddemo_native_smoothprogress);
        card.setUseProgressBar(true);
        cards.add(card);
    }
    //Set the adapter
    mCardArrayAdapter = new CardArrayRecyclerViewAdapter(getActivity(), cards);
    CardRecyclerView mRecyclerView = (CardRecyclerView) getActivity().findViewById(R.id.carddemo_extras_recycler_progress);
    mRecyclerView.setHasFixedSize(false);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    //Set the empty view
    if (mRecyclerView != null) {
        mRecyclerView.setAdapter(mCardArrayAdapter);
    }
}
Also used : CardRecyclerView(it.gmariotti.cardslib.library.recyclerview.view.CardRecyclerView) ArrayList(java.util.ArrayList) CardArrayRecyclerViewAdapter(it.gmariotti.cardslib.library.recyclerview.internal.CardArrayRecyclerViewAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) BaseCard(it.gmariotti.cardslib.library.internal.base.BaseCard) ProgressCard(it.gmariotti.cardslib.library.cards.ProgressCard) Card(it.gmariotti.cardslib.library.internal.Card)

Example 65 with Card

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

the class NativeDragDropListFragment method initCard.

/**
     * This method builds a simple list of cards
     */
private void initCard() {
    //Init an array of Cards
    ArrayList<Card> cards = new ArrayList<Card>();
    for (int i = 0; i < 25; i++) {
        PicassoCard card = new PicassoCard(this.getActivity());
        card.setTitle("A simple card loaded with Picasso " + i);
        card.setSecondaryTitle("Simple text..." + i);
        card.setCount(i);
        //Card must have a stable Id.
        card.setId("a" + i);
        card.setSwipeable(true);
        cards.add(card);
    }
    //Set the adapter
    mCardArrayAdapter = new CardDragDropArrayAdapter(getActivity(), cards);
    mListView = (CardListDragDropView) getActivity().findViewById(R.id.carddemo_extra_list_dragdrop);
    if (mListView != null) {
        mListView.setAdapter(mCardArrayAdapter);
    }
    //Listener
    mListView.setOnItemMovedListener(new OnItemMovedListener() {

        @Override
        public void onItemMoved(int originalPosition, int newPosition) {
            Card card = mCardArrayAdapter.getItem(newPosition);
            Toast.makeText(getActivity(), "Card " + card.getId() + " moved to position " + newPosition, Toast.LENGTH_SHORT).show();
        }
    });
}
Also used : OnItemMovedListener(com.nhaarman.listviewanimations.itemmanipulation.dragdrop.OnItemMovedListener) ArrayList(java.util.ArrayList) CardDragDropArrayAdapter(it.gmariotti.cardslib.library.extra.dragdroplist.internal.CardDragDropArrayAdapter) PicassoCard(it.gmariotti.cardslib.demo.extras.cards.PicassoCard) PicassoCard(it.gmariotti.cardslib.demo.extras.cards.PicassoCard) 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