Search in sources :

Example 1 with CardDragDropArrayAdapter

use of it.gmariotti.cardslib.library.extra.dragdroplist.internal.CardDragDropArrayAdapter 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 2 with CardDragDropArrayAdapter

use of it.gmariotti.cardslib.library.extra.dragdroplist.internal.CardDragDropArrayAdapter 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)

Aggregations

OnItemMovedListener (com.nhaarman.listviewanimations.itemmanipulation.dragdrop.OnItemMovedListener)2 PicassoCard (it.gmariotti.cardslib.demo.extras.cards.PicassoCard)2 CardDragDropArrayAdapter (it.gmariotti.cardslib.library.extra.dragdroplist.internal.CardDragDropArrayAdapter)2 Card (it.gmariotti.cardslib.library.internal.Card)2 ArrayList (java.util.ArrayList)2