Search in sources :

Example 1 with TouchViewDraggableManager

use of com.nhaarman.listviewanimations.itemmanipulation.dragdrop.TouchViewDraggableManager in project ListViewAnimations by nhaarman.

the class DynamicListViewActivity method onCreate.

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_dynamiclistview);
    DynamicListView listView = (DynamicListView) findViewById(R.id.activity_dynamiclistview_listview);
    listView.addHeaderView(LayoutInflater.from(this).inflate(R.layout.activity_dynamiclistview_header, listView, false));
    /* Setup the adapter */
    ArrayAdapter<String> adapter = new MyListAdapter(this);
    SimpleSwipeUndoAdapter simpleSwipeUndoAdapter = new SimpleSwipeUndoAdapter(adapter, this, new MyOnDismissCallback(adapter));
    AlphaInAnimationAdapter animAdapter = new AlphaInAnimationAdapter(simpleSwipeUndoAdapter);
    animAdapter.setAbsListView(listView);
    assert animAdapter.getViewAnimator() != null;
    animAdapter.getViewAnimator().setInitialDelayMillis(INITIAL_DELAY_MILLIS);
    listView.setAdapter(animAdapter);
    /* Enable drag and drop functionality */
    listView.enableDragAndDrop();
    listView.setDraggableManager(new TouchViewDraggableManager(R.id.list_row_draganddrop_touchview));
    listView.setOnItemMovedListener(new MyOnItemMovedListener(adapter));
    listView.setOnItemLongClickListener(new MyOnItemLongClickListener(listView));
    /* Enable swipe to dismiss */
    listView.enableSimpleSwipeUndo();
    /* Add new items on item click */
    listView.setOnItemClickListener(new MyOnItemClickListener(listView));
}
Also used : SimpleSwipeUndoAdapter(com.nhaarman.listviewanimations.itemmanipulation.swipedismiss.undo.SimpleSwipeUndoAdapter) AlphaInAnimationAdapter(com.nhaarman.listviewanimations.appearance.simple.AlphaInAnimationAdapter) DynamicListView(com.nhaarman.listviewanimations.itemmanipulation.DynamicListView) TouchViewDraggableManager(com.nhaarman.listviewanimations.itemmanipulation.dragdrop.TouchViewDraggableManager)

Aggregations

AlphaInAnimationAdapter (com.nhaarman.listviewanimations.appearance.simple.AlphaInAnimationAdapter)1 DynamicListView (com.nhaarman.listviewanimations.itemmanipulation.DynamicListView)1 TouchViewDraggableManager (com.nhaarman.listviewanimations.itemmanipulation.dragdrop.TouchViewDraggableManager)1 SimpleSwipeUndoAdapter (com.nhaarman.listviewanimations.itemmanipulation.swipedismiss.undo.SimpleSwipeUndoAdapter)1