// Path: app/src/main/java/me/yifeiyuan/climb/module/gank/ReturnTopEvent.java
// public class ReturnTopEvent {
// }
// 
// Path: app/src/main/java/me/yifeiyuan/climb/tools/bus/OldDriver.java
// public class OldDriver implements IBus {
// 
//     private static OldDriver sIns = new OldDriver();
// 
//     private EventBus mBus = new EventBus();
// 
//     public static OldDriver getIns() {
//         return sIns;
//     }
// 
//     @Override
//     public void post(Object event) {
//         mBus.post(event);
//     }
// 
//     @Override
//     public void register(Object o) {
//         mBus.register(o);
//     }
// 
//     @Override
//     public void unregister(Object o) {
//         mBus.unregister(o);
//     }
// }
// 
// Path: app/src/main/java/me/yifeiyuan/climb/ui/view/OPRecyclerView.java
// public class OpRecyclerView extends RecyclerView implements OpOnScrollListener.OnBottomListener {
// 
//     private static final String TAG = "OPRecyclerView";
// 
// 
//     private OpOnScrollListener mOpOnScrollListener;
//     public OpRecyclerView(Context context) {
//         super(context);
//         init();
//     }
// 
//     public OpRecyclerView(Context context, AttributeSet attrs) {
//         super(context, attrs);
//         init();
//     }
// 
//     public OpRecyclerView(Context context, AttributeSet attrs, int defStyleAttr) {
//         super(context, attrs, defStyleAttr);
//         init();
//     }
// 
//     private void init() {
//     }
// 
//     @Override
//     public void setLayoutManager(LayoutManager layout) {
//         if (null == mOpOnScrollListener) {
//             mOpOnScrollListener = new OpOnScrollListener(layout, this);
//             addOnScrollListener(mOpOnScrollListener);
//         }
//         super.setLayoutManager(layout);
//     }
// 
//     @Override
//     public void setAdapter(Adapter adapter) {
//         // TODO: 16/7/28 wrap the adapter
//         super.setAdapter(adapter);
//     }
// 
//     @Override
//     public void onBottom() {
//         Log.d(TAG, "onBottom: ");
//         if (null != mOnLoadMoreListener) {
//             mOnLoadMoreListener.onLoadMore();
//         }
//     }
// 
// 
//     public void setLoadMoreComplete() {
//         if (null != mOpOnScrollListener) {
//             mOpOnScrollListener.setLoadMoreComplete();
//         }
//     }
// 
//     private OnLoadMoreListener mOnLoadMoreListener;
// 
//     public void setOnLoadMoreListener(OnLoadMoreListener onLoadMoreListener) {
//         mOnLoadMoreListener = onLoadMoreListener;
//     }
// 
//     public interface OnLoadMoreListener {
//         void onLoadMore();
//     }
// 
// }


import butterknife.Bind;
import me.yifeiyuan.climb.R;
import me.yifeiyuan.climb.module.gank.ReturnTopEvent;
import me.yifeiyuan.climb.tools.bus.OldDriver;
import me.yifeiyuan.climb.ui.view.OpRecyclerView;
import rx.Subscriber;
import rx.Subscription;
import android.os.Bundle;
import android.support.annotation.CallSuper;
import android.support.annotation.Nullable;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import org.greenrobot.eventbus.Subscribe;
/*
 * Copyright (C) 2016, 程序亦非猿
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package me.yifeiyuan.climb.base;





/**
 * encapsulate refresh & loadmore
 */
public abstract class RefreshFragment<A extends RecyclerView.Adapter> extends BaseFragment implements SwipeRefreshLayout.OnRefreshListener, OpRecyclerView.OnLoadMoreListener {

    @Bind(R.id.rv)
    protected OpRecyclerView mRecyclerView;

    @Bind(R.id.refresh)
    protected SwipeRefreshLayout mSwipeRefreshLayout;

    @Nullable
    @Bind(R.id.fab)
    protected FloatingActionButton mFab;

    @Nullable
    @Bind(R.id.col)
    protected CoordinatorLayout mCol;

    /**
     * 页码
     */
    protected int mCurrPage = 1;


    @Override
    protected int getLayoutId() {
        return R.layout.base_refresh_fragment;
    }

    /**
     * 处理公用的view的初始化
     *
     * @param savedInstanceState
     */
    @CallSuper
    @Override
    protected void initView(@Nullable Bundle savedInstanceState) {

// Path: app/src/main/java/me/yifeiyuan/climb/module/gank/ReturnTopEvent.java
// public class ReturnTopEvent {
// }
// 
// Path: app/src/main/java/me/yifeiyuan/climb/tools/bus/OldDriver.java
// public class OldDriver implements IBus {
// 
//     private static OldDriver sIns = new OldDriver();
// 
//     private EventBus mBus = new EventBus();
// 
//     public static OldDriver getIns() {
//         return sIns;
//     }
// 
//     @Override
//     public void post(Object event) {
//         mBus.post(event);
//     }
// 
//     @Override
//     public void register(Object o) {
//         mBus.register(o);
//     }
// 
//     @Override
//     public void unregister(Object o) {
//         mBus.unregister(o);
//     }
// }
// 
// Path: app/src/main/java/me/yifeiyuan/climb/ui/view/OPRecyclerView.java
// public class OpRecyclerView extends RecyclerView implements OpOnScrollListener.OnBottomListener {
// 
//     private static final String TAG = "OPRecyclerView";
// 
// 
//     private OpOnScrollListener mOpOnScrollListener;
//     public OpRecyclerView(Context context) {
//         super(context);
//         init();
//     }
// 
//     public OpRecyclerView(Context context, AttributeSet attrs) {
//         super(context, attrs);
//         init();
//     }
// 
//     public OpRecyclerView(Context context, AttributeSet attrs, int defStyleAttr) {
//         super(context, attrs, defStyleAttr);
//         init();
//     }
// 
//     private void init() {
//     }
// 
//     @Override
//     public void setLayoutManager(LayoutManager layout) {
//         if (null == mOpOnScrollListener) {
//             mOpOnScrollListener = new OpOnScrollListener(layout, this);
//             addOnScrollListener(mOpOnScrollListener);
//         }
//         super.setLayoutManager(layout);
//     }
// 
//     @Override
//     public void setAdapter(Adapter adapter) {
//         // TODO: 16/7/28 wrap the adapter
//         super.setAdapter(adapter);
//     }
// 
//     @Override
//     public void onBottom() {
//         Log.d(TAG, "onBottom: ");
//         if (null != mOnLoadMoreListener) {
//             mOnLoadMoreListener.onLoadMore();
//         }
//     }
// 
// 
//     public void setLoadMoreComplete() {
//         if (null != mOpOnScrollListener) {
//             mOpOnScrollListener.setLoadMoreComplete();
//         }
//     }
// 
//     private OnLoadMoreListener mOnLoadMoreListener;
// 
//     public void setOnLoadMoreListener(OnLoadMoreListener onLoadMoreListener) {
//         mOnLoadMoreListener = onLoadMoreListener;
//     }
// 
//     public interface OnLoadMoreListener {
//         void onLoadMore();
//     }
// 
// }


// Path: app/src/main/java/me/yifeiyuan/climb/base/RefreshFragment.java
import butterknife.Bind;
import me.yifeiyuan.climb.R;
import me.yifeiyuan.climb.module.gank.ReturnTopEvent;
import me.yifeiyuan.climb.tools.bus.OldDriver;
import me.yifeiyuan.climb.ui.view.OpRecyclerView;
import rx.Subscriber;
import rx.Subscription;
import android.os.Bundle;
import android.support.annotation.CallSuper;
import android.support.annotation.Nullable;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import org.greenrobot.eventbus.Subscribe;

/*
 * Copyright (C) 2016, 程序亦非猿
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package me.yifeiyuan.climb.base;





/**
 * encapsulate refresh & loadmore
 */
public abstract class RefreshFragment<A extends RecyclerView.Adapter> extends BaseFragment implements SwipeRefreshLayout.OnRefreshListener, OpRecyclerView.OnLoadMoreListener {

    @Bind(R.id.rv)
    protected OpRecyclerView mRecyclerView;

    @Bind(R.id.refresh)
    protected SwipeRefreshLayout mSwipeRefreshLayout;

    @Nullable
    @Bind(R.id.fab)
    protected FloatingActionButton mFab;

    @Nullable
    @Bind(R.id.col)
    protected CoordinatorLayout mCol;

    /**
     * 页码
     */
    protected int mCurrPage = 1;


    @Override
    protected int getLayoutId() {
        return R.layout.base_refresh_fragment;
    }

    /**
     * 处理公用的view的初始化
     *
     * @param savedInstanceState
     */
    @CallSuper
    @Override
    protected void initView(@Nullable Bundle savedInstanceState) {

        OldDriver.getIns().register(this);