/** * Inserts items at given indexes. Will show an entrance animation for the new items if the newly added item is visible. * Will also call {@link Insertable#add(int, Object)} of the root {@link android.widget.BaseAdapter}. * * @param indexItemPairs the index-item pairs to insert. The first argument of the {@code Pair} is the index, the second argument is the item. * * @throws java.lang.IllegalStateException if the adapter that was set does not implement {@link com.nhaarman.listviewanimations.util.Insertable}. */ //public <T> void insert( KeyValuePair<int, T>[] indexItemPairs) { // if (mAnimateAdditionAdapter == null) { // throw new IllegalStateException("Adapter should implement Insertable!"); // } // ((AnimateAdditionAdapter<T>) mAnimateAdditionAdapter).insert(indexItemPairs); //} /** * Insert items at given indexes. Will show an entrance animation for the new items if the newly added item is visible. * Will also call {@link Insertable#add(int, Object)} of the root {@link android.widget.BaseAdapter}. * * @param indexItemPairs the index-item pairs to insert. The first argument of the {@code Pair} is the index, the second argument is the item. * * @throws java.lang.IllegalStateException if the adapter that was set does not implement {@link com.nhaarman.listviewanimations.util.Insertable}. */ //public <T> void insert( Iterable<Pair<Integer, T>> indexItemPairs) { // if (mAnimateAdditionAdapter == null) { // throw new IllegalStateException("Adapter should implement Insertable!"); // } // ((AnimateAdditionAdapter<T>) mAnimateAdditionAdapter).insert(indexItemPairs); //} /** * Sets the {@link com.nhaarman.listviewanimations.itemmanipulation.dragdrop.DraggableManager} to be used * for determining whether an item should be dragged when the user issues a down {@code MotionEvent}. * <p/> * This method does nothing if the drag and drop functionality is not enabled. */ public void setDraggableManager(IDraggableManager draggableManager) { if (mDragAndDropHandler != null) { mDragAndDropHandler.setDraggableManager(draggableManager); } }
/** * Creates a new {@code DragAndDropHandler} for the listview implementation * in given {@link com.nhaarman.listviewanimations.itemmanipulation.dragdrop.DragAndDropListViewWrapper} * * @param dragAndDropListViewWrapper the {@code DragAndDropListViewWrapper} which wraps the listview implementation to use. */ public DragAndDropHandler(DragAndDropListViewWrapper dragAndDropListViewWrapper) { mWrapper = dragAndDropListViewWrapper; if (mWrapper.getAdapter() != null) { setAdapterInternal(mWrapper.getAdapter()); } mScrollHandler = new ScrollHandler(this); mWrapper.setOnScrollListener(mScrollHandler); mDraggableManager = new DefaultDraggableManager(); if (Build.VERSION.SdkInt <= BuildVersionCodes.Kitkat) { mSwitchViewAnimator = new KitKatSwitchViewAnimator(this); } else { mSwitchViewAnimator = new LSwitchViewAnimator(this); } mMobileItemId = INVALID_ID; ViewConfiguration vc = ViewConfiguration.Get(dragAndDropListViewWrapper.getListView().Context); mSlop = vc.ScaledTouchSlop; }
/** * Sets the {@link DraggableManager} to be used for determining whether an item should be dragged when the user issues a down {@code MotionEvent}. */ public void setDraggableManager(IDraggableManager draggableManager) { mDraggableManager = draggableManager; }