Search in sources :

Example 11 with CardArrayAdapter

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

the class NativeListGplayUndoCardFragment method initCards.

private void initCards() {
    //Init an array of Cards
    ArrayList<Card> cards = new ArrayList<Card>();
    for (int i = 0; i < 100; 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.setId("" + i);
        //Only for test, change some icons
        if ((i > 10 && i < 15) || (i > 35 && i < 45)) {
            card.setResourceIdThumbnail(R.drawable.ic_launcher);
        }
        card.init();
        cards.add(card);
    }
    mCardArrayAdapter = new CardArrayAdapter(getActivity(), cards);
    mCardArrayAdapter.setUndoBarUIElements(new UndoBarController.DefaultUndoBarUIElements() {

        @Override
        public SwipeDirectionEnabled isEnabledUndoBarSwipeAction() {
            return SwipeDirectionEnabled.TOPBOTTOM;
        }

        @Override
        public AnimationType getAnimationType() {
            return AnimationType.TOPBOTTOM;
        }
    });
    //Enable undo controller!
    mCardArrayAdapter.setEnableUndo(true);
    //CardListView listView = (CardListView) getActivity().findViewById(R.id.carddemo_list_gplaycard);
    if (mListView != null) {
        mListView.setAdapter(mCardArrayAdapter);
    }
}
Also used : ArrayList(java.util.ArrayList) UndoBarController(it.gmariotti.cardslib.library.view.listener.UndoBarController) CardArrayAdapter(it.gmariotti.cardslib.library.internal.CardArrayAdapter) Card(it.gmariotti.cardslib.library.internal.Card)

Example 12 with CardArrayAdapter

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

the class PicassoFragment 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 < 200; i++) {
        PicassoCard card = new PicassoCard(this.getActivity());
        card.setTitle("A simple card loaded with Picasso " + i);
        card.setSecondaryTitle("Simple text..." + i);
        card.setCount(i);
        cards.add(card);
    }
    //Set the adapter
    CardArrayAdapter mCardArrayAdapter = new CardArrayAdapter(getActivity(), cards);
    CardListView listView = (CardListView) getActivity().findViewById(R.id.carddemo_extra_list_picasso);
    if (listView != null) {
        listView.setAdapter(mCardArrayAdapter);
    }
}
Also used : CardListView(it.gmariotti.cardslib.library.view.CardListView) ArrayList(java.util.ArrayList) CardArrayAdapter(it.gmariotti.cardslib.library.internal.CardArrayAdapter) PicassoCard(it.gmariotti.cardslib.demo.extras.cards.PicassoCard) PicassoCard(it.gmariotti.cardslib.demo.extras.cards.PicassoCard) Card(it.gmariotti.cardslib.library.internal.Card)

Example 13 with CardArrayAdapter

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

the class UniversalImageLoaderFragment method initCard.

/**
     * This method builds a simple card
     */
private void initCard() {
    //Init an array of Cards
    ArrayList<Card> cards = new ArrayList<Card>();
    for (int i = 0; i < 200; i++) {
        UniversalImageLoaderCard card = new UniversalImageLoaderCard(this.getActivity(), options);
        card.setTitle("A simple card loaded with Universal-Image-Loader " + i);
        card.setSecondaryTitle("Simple text..." + i);
        card.setCount(i);
        cards.add(card);
    }
    CardArrayAdapter mCardArrayAdapter = new CardArrayAdapter(getActivity(), cards);
    CardListView listView = (CardListView) getActivity().findViewById(R.id.carddemo_extra_list_picasso);
    if (listView != null) {
        listView.setAdapter(mCardArrayAdapter);
    }
}
Also used : CardListView(it.gmariotti.cardslib.library.view.CardListView) ArrayList(java.util.ArrayList) UniversalImageLoaderCard(it.gmariotti.cardslib.demo.extras.cards.UniversalImageLoaderCard) CardArrayAdapter(it.gmariotti.cardslib.library.internal.CardArrayAdapter) Card(it.gmariotti.cardslib.library.internal.Card) UniversalImageLoaderCard(it.gmariotti.cardslib.demo.extras.cards.UniversalImageLoaderCard)

Example 14 with CardArrayAdapter

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

the class NativeExpandPicassoFragment method initCard.

/**
     * This method builds a simple cards list
     */
private void initCard() {
    //Only for test scope, use images on assets folder
    String[] fileName = { "file:///android_asset/images/sea.jpg", "file:///android_asset/images/snow.jpg", "file:///android_asset/images/water.jpg", "file:///android_asset/images/img2.jpg", "file:///android_asset/images/rose.jpg" };
    //Only for test scope, use 5 different header titles
    int[] resTitleId = { R.string.carddemo_extras_header_expand_area_inside_sea, R.string.carddemo_extras_header_expand_area_inside_snow, R.string.carddemo_extras_header_expand_area_inside_water, R.string.carddemo_extras_header_expand_area_inside_img2, R.string.carddemo_extras_header_expand_area_inside_rose };
    //Remove debugging from Picasso
    Picasso.with(getActivity()).setDebugging(false);
    //Init an array of Cards
    ArrayList<Card> cards = new ArrayList<Card>();
    for (int j = 1; j < 30; j++) {
        for (int i = 0; i < 10; i++) {
            //Card
            CardInside card = new CardInside(this.getActivity());
            //Create a CardHeader
            CardHeader header = new CardHeader(getActivity(), R.layout.carddemo_extras_expandinside_inner_base_header);
            if (i % 2 == 0) {
                //Set the header title
                header.setTitle(getString(resTitleId[(int) (i / 2) % 5]));
                //Add Header to card
                card.addCardHeader(header);
                //Add an expand area
                CardExpandInside expand = new CardExpandInside(getActivity(), fileName[(int) (i / 2) % 5]);
                card.addCardExpand(expand);
            } else {
                //Set the header title
                header.setTitle(getString(R.string.carddemo_extras_header_expand_area_inside));
                //Add Header to card
                card.addCardHeader(header);
                //Only for test scope, use a random number
                int randomNumber = (int) (Math.random() * 6);
                //Add an expand area
                CardExpandInsideSquare expand = new CardExpandInsideSquare(getActivity(), randomNumber);
                card.addCardExpand(expand);
            }
            //Add a viewToClickExpand to enable click on whole card
            ViewToClickToExpand viewToClickToExpand = ViewToClickToExpand.builder().highlightView(false).setupCardElement(ViewToClickToExpand.CardElementUI.CARD);
            card.setViewToClickToExpand(viewToClickToExpand);
            cards.add(card);
        }
    }
    //Set the arrayAdapter
    CardArrayAdapter mCardArrayAdapter = new CardArrayAdapter(getActivity(), cards);
    CardListView listView = (CardListView) getActivity().findViewById(R.id.carddemo_extra_list_mixinside);
    //Add an animator
    AnimationAdapter animCardArrayAdapter = new AlphaInAnimationAdapter(mCardArrayAdapter);
    animCardArrayAdapter.setAbsListView(listView);
    //animCardArrayAdapter.setInitialDelayMillis(500);
    if (listView != null) {
        listView.setExternalAdapter(animCardArrayAdapter, mCardArrayAdapter);
    }
}
Also used : ViewToClickToExpand(it.gmariotti.cardslib.library.internal.ViewToClickToExpand) AlphaInAnimationAdapter(com.nhaarman.listviewanimations.appearance.simple.AlphaInAnimationAdapter) ArrayList(java.util.ArrayList) CardHeader(it.gmariotti.cardslib.library.internal.CardHeader) CardArrayAdapter(it.gmariotti.cardslib.library.internal.CardArrayAdapter) Card(it.gmariotti.cardslib.library.internal.Card) CardListView(it.gmariotti.cardslib.library.view.CardListView) AlphaInAnimationAdapter(com.nhaarman.listviewanimations.appearance.simple.AlphaInAnimationAdapter) AnimationAdapter(com.nhaarman.listviewanimations.appearance.AnimationAdapter)

Example 15 with CardArrayAdapter

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

the class IonFragment 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 < 200; i++) {
        IonCard card = new IonCard(this.getActivity());
        card.setTitle("A simple card loaded with Ion " + i);
        card.setSecondaryTitle("Simple text..." + i);
        card.setCount(i);
        cards.add(card);
    }
    CardArrayAdapter mCardArrayAdapter = new CardArrayAdapter(getActivity(), cards);
    CardListView listView = (CardListView) getActivity().findViewById(R.id.carddemo_extra_list_picasso);
    if (listView != null) {
        listView.setAdapter(mCardArrayAdapter);
    }
}
Also used : CardListView(it.gmariotti.cardslib.library.view.CardListView) IonCard(it.gmariotti.cardslib.demo.extras.cards.IonCard) ArrayList(java.util.ArrayList) CardArrayAdapter(it.gmariotti.cardslib.library.internal.CardArrayAdapter) IonCard(it.gmariotti.cardslib.demo.extras.cards.IonCard) Card(it.gmariotti.cardslib.library.internal.Card)

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