package com.andrognito.pinlockview;

import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;
/* loaded from: classes.dex */
public class ItemSpaceDecoration extends RecyclerView.ItemDecoration {
    private final int mHorizontalSpaceWidth;
    private final boolean mIncludeEdge;
    private final int mSpanCount;
    private final int mVerticalSpaceHeight;

    public ItemSpaceDecoration(int horizontalSpaceWidth, int verticalSpaceHeight, int spanCount, boolean includeEdge) {
        this.mHorizontalSpaceWidth = horizontalSpaceWidth;
        this.mVerticalSpaceHeight = verticalSpaceHeight;
        this.mSpanCount = spanCount;
        this.mIncludeEdge = includeEdge;
    }

    @Override // android.support.v7.widget.RecyclerView.ItemDecoration
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        int position = parent.getChildAdapterPosition(view);
        int i = this.mSpanCount;
        int column = position % i;
        if (this.mIncludeEdge) {
            int i2 = this.mHorizontalSpaceWidth;
            outRect.left = i2 - ((column * i2) / i);
            outRect.right = ((column + 1) * this.mHorizontalSpaceWidth) / this.mSpanCount;
            if (position < this.mSpanCount) {
                outRect.top = this.mVerticalSpaceHeight;
            }
            outRect.bottom = this.mVerticalSpaceHeight;
            return;
        }
        outRect.left = (this.mHorizontalSpaceWidth * column) / i;
        int i3 = this.mHorizontalSpaceWidth;
        outRect.right = i3 - (((column + 1) * i3) / this.mSpanCount);
        if (position >= this.mSpanCount) {
            outRect.top = this.mVerticalSpaceHeight;
        }
    }
}
