Skip to content

Commit

Permalink
Merge pull request nhaarman#232 from BraisGabin/dev
Browse files Browse the repository at this point in the history
Feature: Add setDismissableManager at Adapter level
  • Loading branch information
nhaarman committed Aug 15, 2014
2 parents 7811af2 + d908fe5 commit 31f7dde
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ public void setListViewWrapper(@NonNull final ListViewWrapper listViewWrapper) {
listViewWrapper.getListView().setOnTouchListener(mDismissTouchListener);
}

/**
* Sets the {@link com.nhaarman.listviewanimations.itemmanipulation.swipedismiss.DismissableManager} to specify which views can or cannot be swiped.
*
* @param dismissableManager {@code null} for no restrictions.
*/
public void setDismissableManager(@Nullable final DismissableManager dismissableManager) {
if (mDismissTouchListener == null) {
throw new IllegalStateException("You must call setAbsListView() first.");
}
mDismissTouchListener.setDismissableManager(dismissableManager);
}

/**
* If the adapter's {@link android.widget.AbsListView} is hosted inside a parent(/grand-parent/etc) that can scroll horizontally, horizontal swipes won't
* work, because the parent will prevent touch-events from reaching the {@code AbsListView}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import com.nhaarman.listviewanimations.BaseAdapterDecorator;
import com.nhaarman.listviewanimations.itemmanipulation.DynamicListView;
import com.nhaarman.listviewanimations.itemmanipulation.swipedismiss.DismissableManager;
import com.nhaarman.listviewanimations.util.ListViewWrapper;

/**
Expand All @@ -33,7 +34,7 @@ public abstract class SwipeUndoAdapter extends BaseAdapterDecorator {
/**
* The {@link SwipeUndoTouchListener} that is set to the {@link android.widget.AbsListView}.
*/
@NonNull
@Nullable
private SwipeUndoTouchListener mSwipeUndoTouchListener;

/**
Expand Down Expand Up @@ -63,6 +64,18 @@ public void setListViewWrapper(@NonNull final ListViewWrapper listViewWrapper) {
}
}

/**
* Sets the {@link com.nhaarman.listviewanimations.itemmanipulation.swipedismiss.DismissableManager} to specify which views can or cannot be swiped.
*
* @param dismissableManager {@code null} for no restrictions.
*/
public void setDismissableManager(@Nullable final DismissableManager dismissableManager) {
if (mSwipeUndoTouchListener == null) {
throw new IllegalStateException("You must call setAbsListView() first.");
}
mSwipeUndoTouchListener.setDismissableManager(dismissableManager);
}

public void setSwipeUndoTouchListener(@NonNull final SwipeUndoTouchListener swipeUndoTouchListener) {
mSwipeUndoTouchListener = swipeUndoTouchListener;
}
Expand Down

0 comments on commit 31f7dde

Please sign in to comment.