package com.omega_r.libs.omegarecyclerview.item_decoration;

import android.graphics.Rect;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.omega_r.libs.omegarecyclerview.item_decoration.decoration_helpers.DividerDecorationHelper;

public class SpaceItemDecoration extends BaseItemDecoration {

    private final int space;

    public SpaceItemDecoration(int showDivider, int space) {
        super(showDivider);
        this.space = space;
    }

    @Override
    void getItemOffset(@NonNull Rect outRect, @NonNull RecyclerView parent,
                       @NonNull DividerDecorationHelper helper, int position, int itemCount) {
        if (isShowBeginDivider() && position < 1 || position >= 1) helper.setStart(outRect, space);
        if (isShowEndDivider() && position == itemCount - 1) helper.setEnd(outRect, space);
    }

}


@@ -87,94 +87,8 @@
 ect;
-%0Aimport androidx.annotation.NonNull;%0Aimport androidx.recyclerview.widget.RecyclerView;
 %0A%0Aim
@@ -188,16 +188,158 @@
 elper;%0A%0A
+import androidx.annotation.NonNull;%0Aimport androidx.recyclerview.widget.GridLayoutManager;%0Aimport androidx.recyclerview.widget.RecyclerView;%0A%0A
 public c
@@ -728,24 +728,96 @@
 temCount) %7B%0A
+        int countBeginEndPositions = getCountBeginEndPositions(parent);%0A
         if (
@@ -841,26 +841,36 @@
 r() 
-&& p
+%7C%7C countBeginEndP
 osition
+s
  %3C
- 1 %7C%7C
+=
  pos
@@ -878,13 +878,8 @@
 tion
- %3E= 1
 ) he
@@ -971,9 +971,30 @@
 t - 
-1
+countBeginEndPositions
 ) he
@@ -1029,11 +1029,327 @@
 %0A    %7D%0A%0A
+    private int getCountBeginEndPositions(RecyclerView recyclerView) %7B%0A        RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();%0A        if (layoutManager instanceof GridLayoutManager) %7B%0A            return ((GridLayoutManager) layoutManager).getSpanCount();%0A        %7D else return 1;%0A    %7D%0A%0A
 %7D%0A%0A

Add support GridLayoutManager for itemSpace