// Path: pullrecyclerview/src/main/java/com/andfast/pullrecyclerview/layoutmanager/ILayoutManager.java
// public interface ILayoutManager {
// 
//     int getFirstVisibleItemPosition();
// 
//     int getLastVisibleItemPosition();
// 
//     RecyclerView.LayoutManager getLayoutManager();
// 
//     void setRecyclerAdapter(BaseRecyclerAdapter adapter);
// 
//     boolean isScrollToFooter(int itemCount);
// 
// }
// 
// Path: pullrecyclerview/src/main/java/com/andfast/pullrecyclerview/layoutmanager/XLinearLayoutManager.java
// public class XLinearLayoutManager extends LinearLayoutManager implements ILayoutManager {
// 
//     public XLinearLayoutManager(Context context) {
//         super(context);
//     }
// 
//     public XLinearLayoutManager(Context context, int orientation, boolean reverseLayout) {
//         super(context, orientation, reverseLayout);
//     }
// 
//     public XLinearLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
//         super(context, attrs, defStyleAttr, defStyleRes);
//     }
// 
//     @Override
//     public int getFirstVisibleItemPosition() {
//         return this.findFirstVisibleItemPosition();
//     }
// 
//     @Override
//     public int getLastVisibleItemPosition() {
//         return this.findLastVisibleItemPosition();
//     }
// 
//     @Override
//     public RecyclerView.LayoutManager getLayoutManager() {
//         return this;
//     }
// 
//     @Override
//     public void setRecyclerAdapter(BaseRecyclerAdapter adapter) {
// 
//     }
// 
//     @Override
//     public boolean isScrollToFooter(int itemCount) {
//         int position = findLastVisibleItemPosition();
//         return position == itemCount - 1;
//     }
// }


import android.content.Context;
import android.support.annotation.ColorRes;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import com.andfast.pullrecyclerview.layoutmanager.ILayoutManager;
import com.andfast.pullrecyclerview.layoutmanager.XLinearLayoutManager;

    public int getFirstVisibleItemPosition() {
        return layoutManager.getFirstVisibleItemPosition();
    }

    public RecyclerView getRecycler() {
        return recyclerView;
    }

    /**
     * 触发PullRecyclerView的下拉刷新
     */
    public void postRefreshing() {
        swipeRefreshLayout.post(new Runnable() {
            @Override
            public void run() {
                swipeRefreshLayout.setRefreshing(true);
                onRefresh();
            }
        });
    }

    /**
     * 设置adapter，需要使用BaseRecyclerAdapter的子类
     * @param adapter
     */
    public void setAdapter(BaseRecyclerAdapter adapter) {
        this.adapter = adapter;
        recyclerView.setAdapter(adapter);
        if (layoutManager == null) {
// Path: pullrecyclerview/src/main/java/com/andfast/pullrecyclerview/layoutmanager/ILayoutManager.java
// public interface ILayoutManager {
// 
//     int getFirstVisibleItemPosition();
// 
//     int getLastVisibleItemPosition();
// 
//     RecyclerView.LayoutManager getLayoutManager();
// 
//     void setRecyclerAdapter(BaseRecyclerAdapter adapter);
// 
//     boolean isScrollToFooter(int itemCount);
// 
// }
// 
// Path: pullrecyclerview/src/main/java/com/andfast/pullrecyclerview/layoutmanager/XLinearLayoutManager.java
// public class XLinearLayoutManager extends LinearLayoutManager implements ILayoutManager {
// 
//     public XLinearLayoutManager(Context context) {
//         super(context);
//     }
// 
//     public XLinearLayoutManager(Context context, int orientation, boolean reverseLayout) {
//         super(context, orientation, reverseLayout);
//     }
// 
//     public XLinearLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
//         super(context, attrs, defStyleAttr, defStyleRes);
//     }
// 
//     @Override
//     public int getFirstVisibleItemPosition() {
//         return this.findFirstVisibleItemPosition();
//     }
// 
//     @Override
//     public int getLastVisibleItemPosition() {
//         return this.findLastVisibleItemPosition();
//     }
// 
//     @Override
//     public RecyclerView.LayoutManager getLayoutManager() {
//         return this;
//     }
// 
//     @Override
//     public void setRecyclerAdapter(BaseRecyclerAdapter adapter) {
// 
//     }
// 
//     @Override
//     public boolean isScrollToFooter(int itemCount) {
//         int position = findLastVisibleItemPosition();
//         return position == itemCount - 1;
//     }
// }


// Path: pullrecyclerview/src/main/java/com/andfast/pullrecyclerview/PullRecyclerView.java
import android.content.Context;
import android.support.annotation.ColorRes;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import com.andfast.pullrecyclerview.layoutmanager.ILayoutManager;
import com.andfast.pullrecyclerview.layoutmanager.XLinearLayoutManager;


    public int getFirstVisibleItemPosition() {
        return layoutManager.getFirstVisibleItemPosition();
    }

    public RecyclerView getRecycler() {
        return recyclerView;
    }

    /**
     * 触发PullRecyclerView的下拉刷新
     */
    public void postRefreshing() {
        swipeRefreshLayout.post(new Runnable() {
            @Override
            public void run() {
                swipeRefreshLayout.setRefreshing(true);
                onRefresh();
            }
        });
    }

    /**
     * 设置adapter，需要使用BaseRecyclerAdapter的子类
     * @param adapter
     */
    public void setAdapter(BaseRecyclerAdapter adapter) {
        this.adapter = adapter;
        recyclerView.setAdapter(adapter);
        if (layoutManager == null) {
            layoutManager = new XLinearLayoutManager(getContext());