Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SimpleItemTouchHelperCallback #30

Open
shiqikai opened this issue Jan 21, 2016 · 0 comments
Open

SimpleItemTouchHelperCallback #30

shiqikai opened this issue Jan 21, 2016 · 0 comments

Comments

@shiqikai
Copy link

@OverRide
public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
// Set movement flags based on the layout manager
if (recyclerView.getLayoutManager() instanceof GridLayoutManager) {
final int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT;
final int swipeFlags = 0;
return makeMovementFlags(dragFlags, swipeFlags);
} else if (viewHolder instanceof ItemTouchHelperViewHolder) {
//Only ViewHolder implents ItemTouchHelperViewHolder can be draged.
final int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
final int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END;
return makeMovementFlags(dragFlags, swipeFlags);
} else {
//others can not be draged.
final int swipeFlags = 0;
final int dragFlags = 0;
return makeMovementFlags(dragFlags, swipeFlags);
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant