package com.veyndan.redditclient.ui.recyclerview.itemdecoration;

import android.content.Context;
import android.graphics.Rect;
import android.support.annotation.DimenRes;
import android.support.v7.widget.RecyclerView;
import android.view.View;

public class MarginItemDecoration extends RecyclerView.ItemDecoration {

    private final int margin;

    public MarginItemDecoration(final Context context, @DimenRes final int marginRes) {
        margin = context.getResources().getDimensionPixelOffset(marginRes);
    }

    @Override
    public void getItemOffsets(final Rect outRect, final View view, final RecyclerView parent,
                               final RecyclerView.State state) {
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) view.getLayoutParams();
        final int position = params.getViewLayoutPosition();
        final int marginTop = position == 0 ? margin : 0;
        outRect.set(margin, marginTop, margin, margin);
    }
}

@@ -165,16 +165,97 @@
 menRes;%0A
+import android.support.annotation.NonNull;%0Aimport android.support.annotation.Px;%0A
 import a
@@ -397,16 +397,20 @@
  %7B%0A%0A    
+@Px 
 private 
@@ -460,16 +460,25 @@
 oration(
+@NonNull 
 final Co

Annotate parameter and field for better compiler checking