Search in sources :

Example 1 with CardGridStaggeredView

use of it.gmariotti.cardslib.library.extra.staggeredgrid.view.CardGridStaggeredView in project cardslib by gabrielemariotti.

the class StaggeredGridFragment 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);
    //Staggered grid view
    CardGridStaggeredView staggeredView = (CardGridStaggeredView) getActivity().findViewById(R.id.carddemo_extras_grid_stag);
    //Set the empty view
    staggeredView.setEmptyView(getActivity().findViewById(android.R.id.empty));
    if (staggeredView != null) {
        staggeredView.setAdapter(mCardArrayAdapter);
    }
    //Load cards
    new LoaderAsyncTask().execute();
}
Also used : ArrayList(java.util.ArrayList) CardGridStaggeredArrayAdapter(it.gmariotti.cardslib.library.extra.staggeredgrid.internal.CardGridStaggeredArrayAdapter) CardGridStaggeredView(it.gmariotti.cardslib.library.extra.staggeredgrid.view.CardGridStaggeredView) Card(it.gmariotti.cardslib.library.internal.Card)

Example 2 with CardGridStaggeredView

use of it.gmariotti.cardslib.library.extra.staggeredgrid.view.CardGridStaggeredView 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 3 with CardGridStaggeredView

use of it.gmariotti.cardslib.library.extra.staggeredgrid.view.CardGridStaggeredView in project cardslib by gabrielemariotti.

the class NativeStaggeredGridFragment 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);
    //Staggered grid view
    CardGridStaggeredView staggeredView = (CardGridStaggeredView) getActivity().findViewById(R.id.carddemo_extras_grid_stag);
    //Set the empty view
    staggeredView.setEmptyView(getActivity().findViewById(android.R.id.empty));
    if (staggeredView != null) {
        staggeredView.setAdapter(mCardArrayAdapter);
    }
    //Load cards
    new LoaderAsyncTask().execute();
}
Also used : ArrayList(java.util.ArrayList) CardGridStaggeredArrayAdapter(it.gmariotti.cardslib.library.extra.staggeredgrid.internal.CardGridStaggeredArrayAdapter) CardGridStaggeredView(it.gmariotti.cardslib.library.extra.staggeredgrid.view.CardGridStaggeredView) Card(it.gmariotti.cardslib.library.internal.Card)

Aggregations

CardGridStaggeredArrayAdapter (it.gmariotti.cardslib.library.extra.staggeredgrid.internal.CardGridStaggeredArrayAdapter)3 CardGridStaggeredView (it.gmariotti.cardslib.library.extra.staggeredgrid.view.CardGridStaggeredView)3 Card (it.gmariotti.cardslib.library.internal.Card)3 ArrayList (java.util.ArrayList)3 BaseCard (it.gmariotti.cardslib.library.internal.base.BaseCard)1