@Override
    public void onChildDraw(@NonNull Canvas c,
                            @NonNull RecyclerView recyclerView,
                            @NonNull RecyclerView.ViewHolder viewHolder,
                            float dX, float dY, int actionState, boolean isCurrentlyActive) {
        if (recyclerView.getId() == R.id.recycler_view_groups) {
            final GroupAdapter adapter = (GroupAdapter) recyclerView.getAdapter();
            if (adapter != null) {
                final int count = adapter.getModelCount(viewHolder.getAbsoluteAdapterPosition());
                if (count > 0) {
                    if (dX > -1100.0f && dX < 1100.0f && dX != 0) {
                        getDefaultUIUtil().onDraw(c, recyclerView, ((RemovableViewHolder) viewHolder).getSwipeableView(), dX, dY, actionState, isCurrentlyActive);
                        swipeBack = true;
                    } else {
                        if (dX == 0 && !swipeBack) {
                            mAdapter.onItemDismissFailed((RemovableViewHolder) viewHolder);
                        }
                    }
                } else {
                    getDefaultUIUtil().onDraw(c, recyclerView, ((RemovableViewHolder) viewHolder).getSwipeableView(), dX, dY, actionState, isCurrentlyActive);
                }
            }
        } else if (recyclerView.getId() == R.id.recycler_view_provisioned_nodes) {
            final NodeAdapter adapter = (NodeAdapter) recyclerView.getAdapter();
            if (adapter != null) {
                if (dX > -800.0f && dX < 800.0f && dX != 0) {
                    getDefaultUIUtil().onDraw(c, recyclerView, ((RemovableViewHolder) viewHolder).getSwipeableView(), dX, dY, actionState, isCurrentlyActive);
                    //swipeBack = true;
                } else {
                    if (dX == 0 && !swipeBack) {
                        mAdapter.onItemDismissFailed((RemovableViewHolder) viewHolder);
                    }
                }
            }
        } else {
            getDefaultUIUtil().onDraw(c, recyclerView, ((RemovableViewHolder) viewHolder).getSwipeableView(), dX, dY, actionState, isCurrentlyActive);
        }

        final RemovableViewHolder vHolder = ((RemovableViewHolder) viewHolder);
        final ImageView view = vHolder.getDeleteView();
        final FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(view.getLayoutParams());
        final int margin = (int) recyclerView.getContext().getResources().getDimension(R.dimen.activity_horizontal_margin);
        if (mPreviousDx <= 0 && dX > 0) {
            // swiping from left to right
            if (layoutParams.gravity != (Gravity.CENTER_VERTICAL | Gravity.START)) {
                layoutParams.gravity = Gravity.CENTER_VERTICAL | Gravity.START;
                layoutParams.setMarginStart(margin);
                layoutParams.setMarginEnd(margin);
                view.setLayoutParams(layoutParams);
            }
        } else if (mPreviousDx >= 0 && dX < 0) {
            // swiping from right to left
            if (layoutParams.gravity != (Gravity.CENTER_VERTICAL | Gravity.START)) {
                layoutParams.gravity = Gravity.CENTER_VERTICAL | Gravity.END;
                layoutParams.setMarginStart(margin);
                layoutParams.setMarginEnd(margin);
                view.setLayoutParams(layoutParams);
            }
        }
        mPreviousDx = dX;
    }
This callback works with {@link RemovableViewHolder}. Only view holders that inherit from this class may be removed.
app/src/main/java/no/nordicsemi/android/nrfmesh/widgets/RemovableItemTouchHelperCallback.java