// Path: libary/src/main/java/com/lain/loadmorehelper/list/IFooterViewCreator.java
// public interface IFooterViewCreator {
//     View getView(ViewGroup parent);
// }
// 
// Path: libary/src/main/java/com/lain/loadmorehelper/list/IListWrapper.java
// public interface IListWrapper {
//     public static final int STATE_INITIAL = 0;
//     public static final int STATE_LOAD_MORE = 1;
//     public static final int STATE_LOAD_FAILED = 2;
//     public static final int STATE_LOAD_COMPLETE = 3;
// 
//     void init(LoadController<?> loadController);
// 
//     void setState(@ListState int curState);
// 
//     @IntDef({STATE_INITIAL, STATE_LOAD_MORE, STATE_LOAD_FAILED, STATE_LOAD_COMPLETE})
//     @Retention(RetentionPolicy.SOURCE)
//     @interface ListState {
// 
//     }
// 
// }


import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.SparseArray;
import android.view.View;
import android.view.ViewGroup;
import com.lain.loadmorehelper.list.IFooterViewCreator;
import com.lain.loadmorehelper.list.IListWrapper;
import static com.lain.loadmorehelper.list.IListWrapper.STATE_INITIAL;
import static com.lain.loadmorehelper.list.IListWrapper.STATE_LOAD_MORE;
import static com.lain.loadmorehelper.list.IListWrapper.STATE_LOAD_FAILED;
    @Override
    public int getItemCount() {
        return getInnerItemCount();
    }

    @Override
    public long getItemId(int position) {
        if (isFooterPosition(position)) {
            return -1;
        }
        return getWrappedAdapter().getItemId(position);
    }

    private int getInnerItemCount() {
        int wrapperItemCount = getWrappedAdapter().getItemCount();
        if (hasLoadMoreView() || hasFailedView() || hasCompleteView()) {
            return wrapperItemCount + 1;
        }
        return wrapperItemCount;
    }

    private boolean isFooterPosition(int pos) {
        if (pos == getInnerItemCount() - 1) {
            return true;
        }
        return false;
    }


    private boolean isFooterViewType(int viewType) {
// Path: libary/src/main/java/com/lain/loadmorehelper/list/IFooterViewCreator.java
// public interface IFooterViewCreator {
//     View getView(ViewGroup parent);
// }
// 
// Path: libary/src/main/java/com/lain/loadmorehelper/list/IListWrapper.java
// public interface IListWrapper {
//     public static final int STATE_INITIAL = 0;
//     public static final int STATE_LOAD_MORE = 1;
//     public static final int STATE_LOAD_FAILED = 2;
//     public static final int STATE_LOAD_COMPLETE = 3;
// 
//     void init(LoadController<?> loadController);
// 
//     void setState(@ListState int curState);
// 
//     @IntDef({STATE_INITIAL, STATE_LOAD_MORE, STATE_LOAD_FAILED, STATE_LOAD_COMPLETE})
//     @Retention(RetentionPolicy.SOURCE)
//     @interface ListState {
// 
//     }
// 
// }


// Path: libary/src/main/java/com/lain/loadmorehelper/list/recyclerview/FooterViewAdapter.java
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.SparseArray;
import android.view.View;
import android.view.ViewGroup;
import com.lain.loadmorehelper.list.IFooterViewCreator;
import com.lain.loadmorehelper.list.IListWrapper;
import static com.lain.loadmorehelper.list.IListWrapper.STATE_INITIAL;
import static com.lain.loadmorehelper.list.IListWrapper.STATE_LOAD_MORE;
import static com.lain.loadmorehelper.list.IListWrapper.STATE_LOAD_FAILED;

    @Override
    public int getItemCount() {
        return getInnerItemCount();
    }

    @Override
    public long getItemId(int position) {
        if (isFooterPosition(position)) {
            return -1;
        }
        return getWrappedAdapter().getItemId(position);
    }

    private int getInnerItemCount() {
        int wrapperItemCount = getWrappedAdapter().getItemCount();
        if (hasLoadMoreView() || hasFailedView() || hasCompleteView()) {
            return wrapperItemCount + 1;
        }
        return wrapperItemCount;
    }

    private boolean isFooterPosition(int pos) {
        if (pos == getInnerItemCount() - 1) {
            return true;
        }
        return false;
    }


    private boolean isFooterViewType(int viewType) {
        return viewType == VIEW_TYPE_LOADMORE || viewType == VIEW_TYPE_LOADFAILED || viewType == VIEW_TYPE_COMPLETE;