package com.incendiary.androidcommon.recyclerview;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

/**
 * Created by esafirm on 8/9/16.
 */
public class RecyclerViewAttacher {

    public static RecyclerAttacherBuilder with(RecyclerView recyclerView) {
        return new RecyclerAttacherBuilder(recyclerView);
    }

    public static class RecyclerAttacherBuilder {

        private RecyclerView recyclerView;
        private RecyclerView.LayoutManager layoutManager;
        private RecyclerView.Adapter adapter;
        private RecyclerView.ItemDecoration itemDecoration;

        private boolean hasFixedSize;

        RecyclerAttacherBuilder(RecyclerView recyclerView) {
            this.recyclerView = recyclerView;
            hasFixedSize = true;
        }

        public RecyclerAttacherBuilder hasFixedSize(boolean hasFixedSize) {
            this.hasFixedSize = hasFixedSize;
            return this;
        }

        public RecyclerAttacherBuilder layoutManager(RecyclerView.LayoutManager manager) {
            this.layoutManager = manager;
            return this;
        }

        public RecyclerAttacherBuilder adapter(RecyclerView.Adapter adapter) {
            this.adapter = adapter;
            return this;
        }

        public RecyclerAttacherBuilder itemDecoration(RecyclerView.ItemDecoration itemDecoration) {
            this.itemDecoration = itemDecoration;
            return this;
        }

        public void build() {
            if (layoutManager == null) {
                layoutManager = new LinearLayoutManager(recyclerView.getContext());
            }
            if (itemDecoration != null) recyclerView.addItemDecoration(itemDecoration);
            recyclerView.setLayoutManager(layoutManager);
            recyclerView.setHasFixedSize(hasFixedSize);
            recyclerView.setAdapter(adapter);
        }
    }
}

@@ -192,49 +192,8 @@
  */%0A
-public class RecyclerViewAttacher %7B%0A%0A    
 publ
@@ -256,28 +256,24 @@
 clerView) %7B%0A
-    
     return n
@@ -321,20 +321,16 @@
 %0A    %7D%0A%0A
-    
 public s
@@ -368,28 +368,24 @@
 lder %7B%0A%0A    
- 
-   
 private Recy
@@ -403,28 +403,24 @@
 cyclerView;%0A
-    
     private 
@@ -457,36 +457,32 @@
 outManager;%0A    
-   
- 
 private Recycler
@@ -499,28 +499,24 @@
 er adapter;%0A
-    
     private 
@@ -534,32 +534,34 @@
 w.ItemDecoration
+%5B%5D
  itemDecoration;
@@ -559,27 +559,24 @@
 coration
+s
 ;%0A%0A    
-  
-  
 private 
@@ -598,20 +598,16 @@
 dSize;%0A%0A
-    
     Recy
@@ -659,28 +659,24 @@
 ) %7B%0A        
-   
- 
 this.recycle
@@ -705,20 +705,16 @@
         
-    
 hasFixed
@@ -726,20 +726,16 @@
 = true;%0A
-    
     %7D%0A%0A 
@@ -729,36 +729,32 @@
 rue;%0A    %7D%0A%0A    
- 
-   
 public RecyclerA
@@ -809,28 +809,24 @@
 ) %7B%0A        
-    
 this.hasFixe
@@ -847,36 +847,32 @@
 edSize;%0A        
-   
- 
 return this;%0A   
@@ -868,35 +868,27 @@
 n this;%0A    
-    %7D%0A%0A    
+%7D%0A%0A
     public R
@@ -966,28 +966,24 @@
 ) %7B%0A        
-    
 this.layoutM
@@ -1000,36 +1000,32 @@
 anager;%0A        
-    
 return this;%0A   
@@ -1021,35 +1021,27 @@
 n this;%0A    
-  
-  
 %7D%0A%0A
-    
     public R
@@ -1107,28 +1107,24 @@
 ) %7B%0A        
-    
 this.adapter
@@ -1135,36 +1135,32 @@
 dapter;%0A        
-   
- 
 return this;%0A   
@@ -1148,36 +1148,32 @@
    return this;%0A
-    
     %7D%0A%0A        p
@@ -1163,28 +1163,24 @@
 %0A    %7D%0A%0A    
-  
-  
 public Recyc
@@ -1240,16 +1240,19 @@
 coration
+...
  itemDec
@@ -1258,28 +1258,24 @@
 coration) %7B%0A
-    
         this
@@ -1289,16 +1289,17 @@
 coration
+s
  = itemD
@@ -1313,28 +1313,24 @@
 on;%0A        
-    
 return this;
@@ -1330,20 +1330,16 @@
 n this;%0A
-    
     %7D%0A%0A 
@@ -1341,20 +1341,16 @@
  %7D%0A%0A    
- 
-   
 public v
@@ -1359,28 +1359,24 @@
 d build() %7B%0A
-    
         if (
@@ -1396,28 +1396,24 @@
  == null) %7B%0A
-    
             
@@ -1488,26 +1488,19 @@
         
-    %7D%0A    
+%7D%0A%0A
         
@@ -1517,16 +1517,17 @@
 coration
+s
  != null
@@ -1532,44 +1532,135 @@
 ll) 
-recyclerView.addItemDecoration(itemD
+%7B%0A            for (RecyclerView.ItemDecoration decoration : itemDecorations) %7B%0A                recyclerView.addItemDecoration(d
 ecor
@@ -1667,24 +1667,45 @@
 ation);%0A    
+        %7D%0A        %7D%0A%0A
         recy
@@ -1742,28 +1742,24 @@
 utManager);%0A
-    
         recy
@@ -1798,36 +1798,32 @@
 dSize);%0A        
-    
 recyclerView.set
@@ -1840,26 +1840,16 @@
 apter);%0A
-        %7D%0A
     %7D%0A%7D%0A

Change ItemDecoration to be Varargs for multiple decoration