package com.omega_r.libs.omegarecyclerview;


import android.support.v7.widget.RecyclerView;

import java.util.Arrays;

public abstract class BaseArrayAdapter<M, VH extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<VH> {

    private M[] mArray;

    public BaseArrayAdapter(M[] array) {
        mArray = array;
    }

    public int getItemCount() {
        return mArray.length;
    }

    public M getItem(int position) {
        return mArray[position];
    }

    public void set(M... array) {
        mArray = array;
        notifyDataSetChanged();
    }

    public void add(M... array) {
        concatAll(mArray, array);
        notifyItemRangeInserted(mArray.length, array.length);
    }

    private static <T> T[] concatAll(T[] first, T[]... rest) {
        int totalLength = first.length;

        for (T[] array : rest) {
            totalLength += array.length;
        }

        T[] result = Arrays.copyOf(first, totalLength);
        int offset = first.length;

        for (T[] array : rest) {
            System.arraycopy(array, 0, result, offset, array.length);
            offset += array.length;
        }

        return result;
    }
}
@@ -87,16 +87,48 @@
 rView;%0A%0A
+import java.lang.reflect.Array;%0A
 import j
@@ -647,19 +647,16 @@
   concat
-All
 (mArray,
@@ -761,20 +761,15 @@
 T%3E T
-%5B%5D
  concat
-All
 (T%5B%5D
@@ -833,94 +833,23 @@
 ngth
-;%0A%0A        for (T%5B%5D array : rest) %7B%0A            totalLength += array.length;%0A        %7D
+ + rest.length;
 %0A%0A  
@@ -855,18 +855,16 @@
        T
-%5B%5D
  result 
@@ -864,16 +864,20 @@
 result =
+ (T)
  Arrays.
@@ -904,24 +904,25 @@
 ength);%0A
+%0A
         
 int offs
@@ -917,20 +917,45 @@
     
-int offset =
+System.arraycopy(first, 0, result, 0,
  fir
@@ -967,48 +967,11 @@
 ngth
+)
 ;%0A
-%0A        for (T%5B%5D array : rest) %7B%0A    
     
@@ -991,21 +991,20 @@
 raycopy(
-array
+rest
 , 0, res
@@ -1012,76 +1012,35 @@
 lt, 
-offset, array.length);%0A            offset += array.length;%0A        %7D
+first.length, rest.length);
 %0A%0A  

change concat method