Search in sources :

Example 1 with PicassoCard

use of it.gmariotti.cardslib.demo.extras.cards.PicassoCard 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 2 with PicassoCard

use of it.gmariotti.cardslib.demo.extras.cards.PicassoCard in project cardslib by gabrielemariotti.

the class StickyListHeadersFragment 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());
        //Use the first letter for sticky
        String firstLetter = calculateFirstLetter(i);
        card.setTitle(firstLetter + " : simple title " + i);
        card.setSecondaryTitle("Simple text..." + i);
        card.setCount(i);
        cards.add(card);
    }
    //Set the adapter
    StickyCardArrayAdapter adapter = new StickyCardArrayAdapter(getActivity(), cards);
    StickyCardListView stickyList = (StickyCardListView) getActivity().findViewById(R.id.carddemo_extra_sticky_list);
    //stickyList.setAreHeadersSticky(false);
    if (stickyList != null) {
        stickyList.setAdapter(adapter);
    }
}
Also used : StickyCardArrayAdapter(it.gmariotti.cardslib.demo.extras.stickylist.StickyCardArrayAdapter) StickyCardListView(it.gmariotti.cardslib.demo.extras.stickylist.StickyCardListView) ArrayList(java.util.ArrayList) PicassoCard(it.gmariotti.cardslib.demo.extras.cards.PicassoCard) PicassoCard(it.gmariotti.cardslib.demo.extras.cards.PicassoCard) Card(it.gmariotti.cardslib.library.internal.Card)

Example 3 with PicassoCard

use of it.gmariotti.cardslib.demo.extras.cards.PicassoCard 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)

Example 4 with PicassoCard

use of it.gmariotti.cardslib.demo.extras.cards.PicassoCard in project cardslib by gabrielemariotti.

the class DragDropListFragment 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)

Example 5 with PicassoCard

use of it.gmariotti.cardslib.demo.extras.cards.PicassoCard in project cardslib by gabrielemariotti.

the class NativePicassoFragment 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)

Aggregations

PicassoCard (it.gmariotti.cardslib.demo.extras.cards.PicassoCard)6 Card (it.gmariotti.cardslib.library.internal.Card)6 ArrayList (java.util.ArrayList)6 OnItemMovedListener (com.nhaarman.listviewanimations.itemmanipulation.dragdrop.OnItemMovedListener)2 CardDragDropArrayAdapter (it.gmariotti.cardslib.library.extra.dragdroplist.internal.CardDragDropArrayAdapter)2 CardArrayAdapter (it.gmariotti.cardslib.library.internal.CardArrayAdapter)2 CardListView (it.gmariotti.cardslib.library.view.CardListView)2 StickyCardArrayAdapter (it.gmariotti.cardslib.demo.extras.stickylist.StickyCardArrayAdapter)1 StickyCardListView (it.gmariotti.cardslib.demo.extras.stickylist.StickyCardListView)1