Java Code Examples for androidx.recyclerview.widget.ItemTouchHelper#DOWN

The following examples show how to use androidx.recyclerview.widget.ItemTouchHelper#DOWN . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ItemMoveCallback.java    From RecyclerViewHelper with Apache License 2.0 6 votes vote down vote up
@Override
public int getMovementFlags(@NonNull RecyclerView recyclerView,
                            @NonNull RecyclerView.ViewHolder viewHolder) {
    // Set movement flags based on the layout manager.
    int swipeFlags = 0;
    int dragFlags;
    if (recyclerView.getLayoutManager() instanceof GridLayoutManager) {
        dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN
                | ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT;
    } else {
        if (mIsFreedom) {
            dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN
                    | ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT;
        } else {
            dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
        }
    }
    return makeMovementFlags(dragFlags, swipeFlags);
}
 
Example 2
Source File: ItemTouchHelperCallback.java    From FlexibleAdapter with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
    RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
    int dragFlags;
    int swipeFlags;
    // Set movement flags based on the Layout Manager and Orientation
    if (layoutManager instanceof GridLayoutManager || layoutManager instanceof StaggeredGridLayoutManager) {
        dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT;
        swipeFlags = 0;
    } else if (LayoutUtils.getOrientation(recyclerView) == LinearLayoutManager.HORIZONTAL) {
        dragFlags = ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT;
        swipeFlags = mSwipeFlags > 0 ? mSwipeFlags : ItemTouchHelper.UP | ItemTouchHelper.DOWN;
    } else {
        dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
        swipeFlags = mSwipeFlags > 0 ? mSwipeFlags : ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT;
    }
    // Disallow item swiping or dragging
    if (viewHolder instanceof ViewHolderCallback) {
        ViewHolderCallback viewHolderCallback = (ViewHolderCallback) viewHolder;
        if (!viewHolderCallback.isDraggable()) {
            dragFlags = 0;
        }
        if (!viewHolderCallback.isSwipeable()) {
            swipeFlags = 0;
        }
    }
    return makeMovementFlags(dragFlags, swipeFlags);
}
 
Example 3
Source File: TouchHelperCallback.java    From SimplicityBrowser with MIT License 5 votes vote down vote up
@Override
public int getMovementFlags(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) {
    int position = viewHolder.getAdapterPosition();
    final int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
    int swipeFlags = position == 0 ? 0 : ItemTouchHelper.START | ItemTouchHelper.END;
    return makeMovementFlags(dragFlags, swipeFlags);
}
 
Example 4
Source File: DragItemTouchHelperBuilder.java    From recyclerview-adapters with Apache License 2.0 5 votes vote down vote up
public ItemTouchHelper build() {
    DragItemCallback callback = new DragItemCallback();
    callback.recyclerAdapter = recyclerAdapter;
    callback.draggingMap = draggingMap;
    callback.dragFlags = dragFlags != 0 ? dragFlags : ItemTouchHelper.UP | ItemTouchHelper.DOWN;
    callback.itemMoveListener = itemMoveListener;
    callback.itemTouchStateChangeListener = itemTouchStateChangeListener;

    return new ItemTouchHelper(callback);
}
 
Example 5
Source File: HistoryFragment.java    From mimi-reader with Apache License 2.0 5 votes vote down vote up
private ItemTouchHelper.Callback createTouchHelperCallback() {
    return new ItemTouchHelper.SimpleCallback(ItemTouchHelper.UP | ItemTouchHelper.DOWN, ItemTouchHelper.LEFT) {
        @Override
        public boolean isLongPressDragEnabled() {
            return true;
        }

        @Override
        public boolean isItemViewSwipeEnabled() {
            return false;
        }

        @Override
        public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder from, RecyclerView.ViewHolder to) {
            HistoryAdapter adapter;
            if (recyclerView.getAdapter() instanceof HistoryAdapter) {
                adapter = (HistoryAdapter) recyclerView.getAdapter();
                adapter.swapItems(from.getAdapterPosition(), to.getAdapterPosition());
                return true;
            }

            return false;
        }

        @Override
        public void onSwiped(RecyclerView.ViewHolder viewHolder, int i) {

        }
    };
}
 
Example 6
Source File: ItemTouchHelperCallback.java    From FastLib with Apache License 2.0 5 votes vote down vote up
@Override
public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
    //上下拖拽
    int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
    //向右侧滑
    int swipeFlags = ItemTouchHelper.RIGHT | ItemTouchHelper.LEFT;
    return makeMovementFlags(dragFlags, swipeFlags);
}
 
Example 7
Source File: ItemSwipeCallback.java    From RecyclerViewHelper with Apache License 2.0 5 votes vote down vote up
@Override
public int getMovementFlags(@NonNull RecyclerView recyclerView,
                            @NonNull RecyclerView.ViewHolder viewHolder) {
    // Set movement flags.
    int dragFlags = 0;
    int swipeFlags;
    if (mOrientation == LinearLayout.HORIZONTAL) {
        swipeFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
    } else {
        swipeFlags = ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT;
    }
    return makeMovementFlags(dragFlags, swipeFlags);
}
 
Example 8
Source File: WaypointListAdapter.java    From msdkui-android with Apache License 2.0 5 votes vote down vote up
@Override
public int getMovementFlags(final RecyclerView recyclerView, final RecyclerView.ViewHolder viewHolder) {
    final WaypointEntry entry = mWaypointEntries.get(viewHolder.getAdapterPosition());
    final int dragFlags = entry.isDraggable() ?
            ItemTouchHelper.UP | ItemTouchHelper.DOWN :
            ItemTouchHelper.ACTION_STATE_IDLE;
    return makeMovementFlags(dragFlags, ItemTouchHelper.ACTION_STATE_IDLE);
}
 
Example 9
Source File: SimpleItemTouchHelperCallback.java    From SkyTube with GNU General Public License v3.0 4 votes vote down vote up
@Override
public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
	int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT;
	return makeMovementFlags(dragFlags, 0);
}
 
Example 10
Source File: SimpleItemTouchHelperCallback.java    From financisto with GNU General Public License v2.0 4 votes vote down vote up
@Override
public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
    final int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
    final int swipeFlags = ItemTouchHelper.END | ItemTouchHelper.START;
    return makeMovementFlags(dragFlags, swipeFlags);
}
 
Example 11
Source File: SavedColorListAdapter.java    From revolution-irc with GNU General Public License v3.0 4 votes vote down vote up
@Override
public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
    int dragFlags = ItemTouchHelper.START | ItemTouchHelper.END;
    int swipeFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
    return makeMovementFlags(dragFlags, swipeFlags);
}
 
Example 12
Source File: SwipeAndDragHelper.java    From Music-Player with GNU General Public License v3.0 4 votes vote down vote up
@Override
public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
    int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
    return makeMovementFlags(dragFlags, 0);
}
 
Example 13
Source File: SimpleItemTouchHelperCallback.java    From call_manage with MIT License 4 votes vote down vote up
@Override
public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
    int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
    int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END;
    return makeMovementFlags(dragFlags, swipeFlags);
}
 
Example 14
Source File: SwipeAndDragHelper.java    From VinylMusicPlayer with GNU General Public License v3.0 4 votes vote down vote up
@Override
public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
    int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
    return makeMovementFlags(dragFlags, 0);
}
 
Example 15
Source File: SortFragment.java    From prayer-times-android with Apache License 2.0 4 votes vote down vote up
@Override
public int getMovementFlags(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) {
    int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
    int swipeFlags = ItemTouchHelper.END;
    return makeMovementFlags(dragFlags, swipeFlags);
}
 
Example 16
Source File: RecyclerViewExampleActivity.java    From realm-android-adapters with Apache License 2.0 4 votes vote down vote up
TouchHelperCallback() {
    super(ItemTouchHelper.UP | ItemTouchHelper.DOWN, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT);
}
 
Example 17
Source File: QueueItemTouchHelperCallback.java    From CastVideos-android with Apache License 2.0 4 votes vote down vote up
@Override
public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
    final int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
    final int swipeFlags = ItemTouchHelper.END;
    return makeMovementFlags(dragFlags, swipeFlags);
}
 
Example 18
Source File: RejectedCallAdapter.java    From toktok-android with GNU General Public License v3.0 4 votes vote down vote up
@Override
public int getMovementFlags(RecyclerView recyclerView, ViewHolder viewHolder) {
    int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
    return Callback.makeMovementFlags(dragFlags, 0);
}
 
Example 19
Source File: SortFragment.java    From prayer-times-android with Apache License 2.0 4 votes vote down vote up
@Override
public int getMovementFlags(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) {
    int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
    int swipeFlags = ItemTouchHelper.END;
    return makeMovementFlags(dragFlags, swipeFlags);
}
 
Example 20
Source File: ItemTouchHelperCallback.java    From Android-Keyboard with Apache License 2.0 4 votes vote down vote up
@Override
public int getMovementFlags(@NotNull RecyclerView recyclerView, @NotNull RecyclerView.ViewHolder viewHolder) {
    int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
    int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END;
    return makeMovementFlags(dragFlags, swipeFlags);
}