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

The following examples show how to use androidx.recyclerview.widget.ItemTouchHelper#UP . 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: StickerManagementItemTouchHelper.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int getMovementFlags(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) {
  if (callback.isMovable(viewHolder.getAdapterPosition())) {
    int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
    return makeMovementFlags(dragFlags, 0);
  } else {
    return 0;
  }
}
 
Example 3
Source File: FragmentOrder.java    From FairEmail with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int getMovementFlags(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) {
    int flags = 0;
    int pos = viewHolder.getAdapterPosition();
    if (pos != RecyclerView.NO_POSITION) {
        if (pos - 1 >= 0)
            flags |= ItemTouchHelper.UP;
        if (pos + 1 < rvOrder.getAdapter().getItemCount())
            flags |= ItemTouchHelper.DOWN;
    }

    return makeMovementFlags(flags, 0);
}
 
Example 4
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 5
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 6
Source File: DynamicTouchListener.java    From dynamic-support with Apache License 2.0 5 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.START | ItemTouchHelper.END;

    return makeMovementFlags(dragFlags, swipeFlags);
}
 
Example 7
Source File: SimpleItemTouchHelperCallback.java    From UltimateRecyclerView with Apache License 2.0 5 votes vote down vote up
@Override
public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
    // Enable drag and swipe in both directions
    final int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
    final int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END;
    return makeMovementFlags(dragFlags, swipeFlags);
}
 
Example 8
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 9
Source File: SimpleItemTouchHelperCallback.java    From Aegis with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
    int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
    int swipeFlags = 0;

    int position = viewHolder.getAdapterPosition();
    EntryAdapter adapter = (EntryAdapter)recyclerView.getAdapter();
    if (adapter.getEntryAt(position) != _selectedEntry)
    {
        dragFlags = 0;
    }

    return makeMovementFlags(dragFlags, swipeFlags);
}
 
Example 10
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 11
Source File: DownloadFileItemHelperCallback.java    From Audinaut with GNU General Public License v3.0 4 votes vote down vote up
public DownloadFileItemHelperCallback(SubsonicFragment fragment, boolean mainList) {
    super(ItemTouchHelper.UP | ItemTouchHelper.DOWN, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT);
    this.fragment = fragment;
    this.mainList = mainList;
}
 
Example 12
Source File: ItemTouchHelperCallback.java    From PhoneProfilesPlus 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.START | ItemTouchHelper.END;
    return makeMovementFlags(dragFlags, swipeFlags);
}
 
Example 13
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 14
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 15
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 16
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 17
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 18
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 19
Source File: ItemMoveCallback.java    From indigenous-android 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 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);
}