// Path: app/src/main/java/com/andfast/app/constant/GeneralID.java
// public class GeneralID {
// 
//     /**接口根地址*/
//     public static final String BASE_SERVER_URL = "http://is.snssdk.com/";
// 
//     /**
//      * 页面间参数传递KEY值
//      */
//     public class Extra {
//         public static final String TAB = "tab";
//     }
// 
//     public final static int TYPE_PULL_REFRESH = 1;
//     public final static int TYPE_LOAD_MORE = TYPE_PULL_REFRESH + 1;
// 
//     /**网络请求异常code*/
//     public final static int TYPE_NET_UNAVAILABLE_CODE = 1004;
//     public final static int TYPE_NET_ERROR_CODE = TYPE_NET_UNAVAILABLE_CODE+1;
// 
//     // EventBus Code
//     public static final class EventCode {
//         public static final int TEST = 0x8858111;
//     }
// }
// 
// Path: app/src/main/java/com/andfast/app/model/Topic.java
// public class Topic {
//     public String id;
//     public String author_id;
//     public String tab;
//     public String content;
//     public String title;
//     public Date last_reply_at;
//     public boolean good;
//     public boolean top;
//     public Integer reply_count;
//     public Integer visit_count;
//     public Date create_at;
//     public Author author;
// 
//     public class Author{
//         public String loginname;
//         public String avatar_url;
//     }
// }
// 
// Path: app/src/main/java/com/andfast/app/net/ResultResponse.java
// public class ResultResponse <T> {
// 
//     public String has_more;
//     public String message;
//     public boolean success;
//     public int error_code;
//     public T data;
// 
//     public ResultResponse(String more, int code,boolean success,String _message, T result) {
//         error_code = code;
//         has_more = more;
//         message = _message;
//         data = result;
//         this.success = success;
//     }
// }
// 
// Path: app/src/main/java/com/andfast/app/presenter/SubscriberCallBack.java
// public abstract class SubscriberCallBack<T> extends BaseCallBack<ResultResponse<T>> {
//     private static final String TAG = "SubscriberCallBack";
//     @Override
//     public void onNext(ResultResponse<T> resultResponse) {
//         if (resultResponse.success){
//             onSuccess(resultResponse.data);
//         }else {
//             onFailure(resultResponse);
//         }
//     }
// 
//     @Override
//     public void onError(Throwable e) {
//         super.onError(e);
//         onFailure(new ResultResponse("", GeneralID.TYPE_NET_ERROR_CODE,false,"",e));
//     }
// 
//     protected abstract void onFailure(ResultResponse response);
//     protected abstract void onSuccess(T response);
// }
// 
// Path: app/src/main/java/com/andfast/app/presenter/base/BasePresenter.java
// public class BasePresenter<V> {
// 
//     protected ApiService mApiService = ApiRetrofit.getInstance().getApiService();
//     protected V mView;
//     private CompositeSubscription mCompositeSubscription;
// 
//     public BasePresenter(V view) {
//         attachView(view);
//     }
// 
//     public void attachView(V view) {
//         mView = view;
//     }
// 
//     public void detachView() {
//         mView = null;
//         onUnsubscribe();
//     }
// 
//     public void addSubscription(Observable observable, Subscriber subscriber) {
//         if (mCompositeSubscription == null) {
//             mCompositeSubscription = new CompositeSubscription();
//         }
//         if (!NetworkUtils.isAvailable(AndFastApplication.getContext())){
//             observable = Observable.create(new Observable.OnSubscribe<ResultResponse<V>>() {
//                 @Override
//                 public void call(Subscriber<? super ResultResponse<V>> subscriber) {
//                     subscriber.onNext(new ResultResponse<V>("", GeneralID.TYPE_NET_UNAVAILABLE_CODE,false,"",null));
//                 }
//             });
//         }
//         mCompositeSubscription.add(observable
//                 .subscribeOn(Schedulers.io())
//                 .observeOn(AndroidSchedulers.mainThread())
//                 .subscribe(subscriber));
//     }
// 
//     //RXjava取消注册，以避免内存泄露
//     public void onUnsubscribe() {
//         if (mCompositeSubscription != null && mCompositeSubscription.hasSubscriptions()) {
//             mCompositeSubscription.unsubscribe();
//         }
//     }
// }
// 
// Path: app/src/main/java/com/andfast/app/view/home/Impl/IHomeListView.java
// public interface IHomeListView extends IBasePullListView<List<Topic>> {
// }


import com.andfast.app.constant.GeneralID;
import com.andfast.app.model.Topic;
import com.andfast.app.net.ResultResponse;
import com.andfast.app.presenter.SubscriberCallBack;
import com.andfast.app.presenter.base.BasePresenter;
import com.andfast.app.view.home.Impl.IHomeListView;
import java.util.List;
package com.andfast.app.presenter.home;



/**
 * Created by mby on 17-8-8.
 */

public class HomePresenter extends BasePresenter<IHomeListView> {
    public HomePresenter(IHomeListView view) {
        super(view);
    }

    public void getPullRefresh(){
        addSubscription(mApiService.getTopicPage(1,20,true), new SubscriberCallBack<List<Topic>>() {
            @Override
// Path: app/src/main/java/com/andfast/app/constant/GeneralID.java
// public class GeneralID {
// 
//     /**接口根地址*/
//     public static final String BASE_SERVER_URL = "http://is.snssdk.com/";
// 
//     /**
//      * 页面间参数传递KEY值
//      */
//     public class Extra {
//         public static final String TAB = "tab";
//     }
// 
//     public final static int TYPE_PULL_REFRESH = 1;
//     public final static int TYPE_LOAD_MORE = TYPE_PULL_REFRESH + 1;
// 
//     /**网络请求异常code*/
//     public final static int TYPE_NET_UNAVAILABLE_CODE = 1004;
//     public final static int TYPE_NET_ERROR_CODE = TYPE_NET_UNAVAILABLE_CODE+1;
// 
//     // EventBus Code
//     public static final class EventCode {
//         public static final int TEST = 0x8858111;
//     }
// }
// 
// Path: app/src/main/java/com/andfast/app/model/Topic.java
// public class Topic {
//     public String id;
//     public String author_id;
//     public String tab;
//     public String content;
//     public String title;
//     public Date last_reply_at;
//     public boolean good;
//     public boolean top;
//     public Integer reply_count;
//     public Integer visit_count;
//     public Date create_at;
//     public Author author;
// 
//     public class Author{
//         public String loginname;
//         public String avatar_url;
//     }
// }
// 
// Path: app/src/main/java/com/andfast/app/net/ResultResponse.java
// public class ResultResponse <T> {
// 
//     public String has_more;
//     public String message;
//     public boolean success;
//     public int error_code;
//     public T data;
// 
//     public ResultResponse(String more, int code,boolean success,String _message, T result) {
//         error_code = code;
//         has_more = more;
//         message = _message;
//         data = result;
//         this.success = success;
//     }
// }
// 
// Path: app/src/main/java/com/andfast/app/presenter/SubscriberCallBack.java
// public abstract class SubscriberCallBack<T> extends BaseCallBack<ResultResponse<T>> {
//     private static final String TAG = "SubscriberCallBack";
//     @Override
//     public void onNext(ResultResponse<T> resultResponse) {
//         if (resultResponse.success){
//             onSuccess(resultResponse.data);
//         }else {
//             onFailure(resultResponse);
//         }
//     }
// 
//     @Override
//     public void onError(Throwable e) {
//         super.onError(e);
//         onFailure(new ResultResponse("", GeneralID.TYPE_NET_ERROR_CODE,false,"",e));
//     }
// 
//     protected abstract void onFailure(ResultResponse response);
//     protected abstract void onSuccess(T response);
// }
// 
// Path: app/src/main/java/com/andfast/app/presenter/base/BasePresenter.java
// public class BasePresenter<V> {
// 
//     protected ApiService mApiService = ApiRetrofit.getInstance().getApiService();
//     protected V mView;
//     private CompositeSubscription mCompositeSubscription;
// 
//     public BasePresenter(V view) {
//         attachView(view);
//     }
// 
//     public void attachView(V view) {
//         mView = view;
//     }
// 
//     public void detachView() {
//         mView = null;
//         onUnsubscribe();
//     }
// 
//     public void addSubscription(Observable observable, Subscriber subscriber) {
//         if (mCompositeSubscription == null) {
//             mCompositeSubscription = new CompositeSubscription();
//         }
//         if (!NetworkUtils.isAvailable(AndFastApplication.getContext())){
//             observable = Observable.create(new Observable.OnSubscribe<ResultResponse<V>>() {
//                 @Override
//                 public void call(Subscriber<? super ResultResponse<V>> subscriber) {
//                     subscriber.onNext(new ResultResponse<V>("", GeneralID.TYPE_NET_UNAVAILABLE_CODE,false,"",null));
//                 }
//             });
//         }
//         mCompositeSubscription.add(observable
//                 .subscribeOn(Schedulers.io())
//                 .observeOn(AndroidSchedulers.mainThread())
//                 .subscribe(subscriber));
//     }
// 
//     //RXjava取消注册，以避免内存泄露
//     public void onUnsubscribe() {
//         if (mCompositeSubscription != null && mCompositeSubscription.hasSubscriptions()) {
//             mCompositeSubscription.unsubscribe();
//         }
//     }
// }
// 
// Path: app/src/main/java/com/andfast/app/view/home/Impl/IHomeListView.java
// public interface IHomeListView extends IBasePullListView<List<Topic>> {
// }


// Path: app/src/main/java/com/andfast/app/presenter/home/HomePresenter.java
import com.andfast.app.constant.GeneralID;
import com.andfast.app.model.Topic;
import com.andfast.app.net.ResultResponse;
import com.andfast.app.presenter.SubscriberCallBack;
import com.andfast.app.presenter.base.BasePresenter;
import com.andfast.app.view.home.Impl.IHomeListView;
import java.util.List;

package com.andfast.app.presenter.home;



/**
 * Created by mby on 17-8-8.
 */

public class HomePresenter extends BasePresenter<IHomeListView> {
    public HomePresenter(IHomeListView view) {
        super(view);
    }

    public void getPullRefresh(){
        addSubscription(mApiService.getTopicPage(1,20,true), new SubscriberCallBack<List<Topic>>() {
            @Override
            protected void onFailure(ResultResponse response) {