@@ -0,0 +1,2039 @@
+package com.fivehundredpx.greedolayout;%0A%0Aimport android.graphics.Rect;%0Aimport android.support.v7.widget.RecyclerView;%0Aimport android.view.View;%0A%0A/**%0A * Created by Julian Villella on 15-07-30.%0A */%0Apublic class AspectRatioSpacingItemDecoration extends RecyclerView.ItemDecoration %7B%0A    public static int DEFAULT_SPACING = 64;%0A    private int mSpacing;%0A%0A    public AspectRatioSpacingItemDecoration() %7B%0A        this(DEFAULT_SPACING);%0A    %7D%0A%0A    public AspectRatioSpacingItemDecoration(int spacing) %7B%0A        mSpacing = spacing;%0A    %7D%0A%0A    @Override%0A    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) %7B%0A        if (!(parent.getLayoutManager() instanceof AspectRatioLayoutManager)) %7B%0A            throw new IllegalArgumentException(String.format(%22The %25s must be used with a %25s%22,%0A                    AspectRatioSpacingItemDecoration.class.getSimpleName(), AspectRatioLayoutManager.class.getSimpleName()));%0A        %7D%0A%0A        int childIndex = parent.getChildAdapterPosition(view);%0A%0A        AspectRatioLayoutManager layoutManager = (AspectRatioLayoutManager) parent.getLayoutManager();%0A        AspectRatioLayoutSizeCalculator sizeCalculator = layoutManager.getSizeCalculator();%0A%0A        outRect.top    = 0;%0A        outRect.bottom = mSpacing;%0A        outRect.left   = 0;%0A        outRect.right  = mSpacing;%0A%0A        // Add inter-item spacings (don't add spacings on edges)%0A        if (isTopChild(childIndex, sizeCalculator))%0A            outRect.top = mSpacing;%0A%0A        if (isLeftChild(childIndex, sizeCalculator))%0A            outRect.left = mSpacing;%0A    %7D%0A%0A    private boolean isTopChild(int position, AspectRatioLayoutSizeCalculator sizeCalculator) %7B%0A        return sizeCalculator.getRowForChildPosition(position) == 0;%0A    %7D%0A%0A    private boolean isLeftChild(int position, AspectRatioLayoutSizeCalculator sizeCalculator) %7B%0A        int rowForPosition = sizeCalculator.getRowForChildPosition(position);%0A        return sizeCalculator.getFirstChildPositionForRow(rowForPosition) == position;%0A    %7D%0A%7D%0A

Add AspectRatioSpacingItemDecoration to library