Search in sources :

Example 26 with CardArrayAdapter

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

the class ListSectionedCardFragment method initCards.

/**
     * Init
     */
private void initCards() {
    //Init an array of Cards
    ArrayList<Card> cards = new ArrayList<Card>();
    for (int i = 0; i < 200; i++) {
        GooglePlaySmallCard card = new GooglePlaySmallCard(this.getActivity());
        card.setTitle("Application example " + i);
        card.setSecondaryTitle("A company inc..." + i);
        card.setRating((float) (Math.random() * (5.0)));
        card.count = i;
        card.init();
        //Add card to array
        cards.add(card);
    }
    //Standard array
    CardArrayAdapter mCardArrayAdapter = new CardArrayAdapter(getActivity(), cards);
    // Sections code.
    // Add the card sections
    List<GplayCardSection> sections = new ArrayList<GplayCardSection>();
    sections.add(new GplayCardSection(1, "Section 1", "More"));
    sections.add(new GplayCardSection(3, "Section 2", "Other"));
    GplayCardSection[] dummy = new GplayCardSection[sections.size()];
    //Sectioned adapter
    GPlaySectionedAdapter mAdapter = new GPlaySectionedAdapter(getActivity(), mCardArrayAdapter);
    mAdapter.setCardSections(sections.toArray(dummy));
    CardListView listView = (CardListView) getActivity().findViewById(R.id.carddemo_list_gplaycard);
    if (listView != null) {
        listView.setExternalAdapter(mAdapter, mCardArrayAdapter);
    }
}
Also used : CardListView(it.gmariotti.cardslib.library.view.CardListView) ArrayList(java.util.ArrayList) CardArrayAdapter(it.gmariotti.cardslib.library.internal.CardArrayAdapter) Card(it.gmariotti.cardslib.library.internal.Card)

Example 27 with CardArrayAdapter

use of it.gmariotti.cardslib.library.internal.CardArrayAdapter in project Weather by Sparker0i.

the class AboutActivity method initCards.

public void initCards() {
    cards = new ArrayList<>();
    cards.add(new AboutCard(this, R.layout.about_card_layout_1, 1));
    cards.add(new AboutCard(this, R.layout.about_card_layout_2, 2));
    cards.add(new AboutCard(this, R.layout.about_card_layout_3, 3));
    cards.add(new AboutCard(this, R.layout.about_card_layout_4, 4));
    cards.add(new AboutCard(this, R.layout.about_card_layout_5, 5));
    cardArrayAdapter = new CardArrayAdapter(this, cards);
    if (aboutList != null) {
        aboutList.setAdapter(cardArrayAdapter);
        aboutList.setOnScrollListener(new SwipeOnScrollListener() {

            @Override
            public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
                if (firstVisibleItem > previousVisibleItem)
                    fab.hide();
                else if (firstVisibleItem < previousVisibleItem)
                    fab.show();
                previousVisibleItem = firstVisibleItem;
            }
        });
    }
}
Also used : AbsListView(android.widget.AbsListView) SwipeOnScrollListener(it.gmariotti.cardslib.library.view.listener.SwipeOnScrollListener) AboutCard(com.a5corp.weather.cards.AboutCard) CardArrayAdapter(it.gmariotti.cardslib.library.internal.CardArrayAdapter)

Aggregations

CardArrayAdapter (it.gmariotti.cardslib.library.internal.CardArrayAdapter)27 Card (it.gmariotti.cardslib.library.internal.Card)26 ArrayList (java.util.ArrayList)26 CardListView (it.gmariotti.cardslib.library.view.CardListView)21 BaseCard (it.gmariotti.cardslib.library.internal.base.BaseCard)5 AnimationAdapter (com.nhaarman.listviewanimations.appearance.AnimationAdapter)2 AlphaInAnimationAdapter (com.nhaarman.listviewanimations.appearance.simple.AlphaInAnimationAdapter)2 ColorCard (it.gmariotti.cardslib.demo.cards.ColorCard)2 CustomExpandCard (it.gmariotti.cardslib.demo.cards.CustomExpandCard)2 MayKnowCard (it.gmariotti.cardslib.demo.cards.MayKnowCard)2 ColorCard (it.gmariotti.cardslib.demo.extras.cards.ColorCard)2 PicassoCard (it.gmariotti.cardslib.demo.extras.cards.PicassoCard)2 CardHeader (it.gmariotti.cardslib.library.internal.CardHeader)2 ViewToClickToExpand (it.gmariotti.cardslib.library.internal.ViewToClickToExpand)2 UndoBarController (it.gmariotti.cardslib.library.view.listener.UndoBarController)2 AbsListView (android.widget.AbsListView)1 AboutCard (com.a5corp.weather.cards.AboutCard)1 FloatingActionButton (com.melnykov.fab.FloatingActionButton)1 GoogleNowWeatherCard (it.gmariotti.cardslib.demo.cards.GoogleNowWeatherCard)1 IonCard (it.gmariotti.cardslib.demo.extras.cards.IonCard)1