package dongyushan.bwie.com.lianxi.presenter; import dongyushan.bwie.com.lianxi.view.IBaseView; public class BasePresenter<V extends IBaseView> { private V iv; public void attachView(V iv) { this.iv = iv; } public void dettachView() { this.iv = null; } public V getView() { return iv; } }
package dongyushan.bwie.com.lianxi.presenter; import dongyushan.bwie.com.lianxi.bean.HomeBean; import dongyushan.bwie.com.lianxi.model.HttpUtils; import dongyushan.bwie.com.lianxi.view.IBaseView; import dongyushan.bwie.com.lianxi.view.IFenView; import io.reactivex.Observable; import io.reactivex.Observer; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; import io.reactivex.schedulers.Schedulers; public class FenPresenter extends BasePresenter<IFenView>{ public void loadData() { Observable<HomeBean> shouye = HttpUtils.getHttpUtilsInstance().apiClient.shouye(); shouye.subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Observer<HomeBean>() { @Override public void onSubscribe(Disposable d) { } @Override public void onNext(HomeBean homeBean) { getView().onSuccess(homeBean); } @Override public void onError(Throwable e) { } @Override public void onComplete() { } }); } }
package dongyushan.bwie.com.lianxi.presenter; import dongyushan.bwie.com.lianxi.bean.FenBean; import dongyushan.bwie.com.lianxi.model.HttpUtils; import dongyushan.bwie.com.lianxi.view.IFenView; import io.reactivex.Observable; import io.reactivex.Observer; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; import io.reactivex.schedulers.Schedulers; public class YouPresenter extends BasePresenter<IFenView>{ public void loadDataRight(String cids) { Observable<FenBean> fenlei = HttpUtils.getHttpUtilsInstance().apiClient.fenlei(cids); fenlei.subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Observer<FenBean>() { @Override public void onSubscribe(Disposable d) { } @Override public void onNext(FenBean fenBean) { getView().right(fenBean); } @Override public void onError(Throwable e) { } @Override public void onComplete() { } }); } }
package dongyushan.bwie.com.lianxi.presenter; import android.util.Log; import java.util.List; import dongyushan.bwie.com.lianxi.bean.HomeBean; import dongyushan.bwie.com.lianxi.bean.SouBean; import dongyushan.bwie.com.lianxi.model.HttpUtils; import dongyushan.bwie.com.lianxi.view.ISouView; import io.reactivex.Observable; import io.reactivex.Observer; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; import io.reactivex.schedulers.Schedulers; public class SouPresenter extends BasePresenter <ISouView>{ public void souLoadData(String name,int page) { Observable<SouBean> sousuo = HttpUtils.getHttpUtilsInstance().apiClient.sousuo(name,page); sousuo.subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Observer<SouBean>() { @Override public void onSubscribe(Disposable d) { } @Override public void onNext(SouBean souBean) { List<SouBean.DataBean> data = souBean.getData(); Log.i("ccc",souBean.getData().get(0).getTitle()); getView().onSuccess(data); } @Override public void onError(Throwable e) { } @Override public void onComplete() { } }); } }
package dongyushan.bwie.com.lianxi.presenter; import android.util.Log; import java.util.List; import dongyushan.bwie.com.lianxi.bean.SouBean; import dongyushan.bwie.com.lianxi.bean.XiangQingBean; import dongyushan.bwie.com.lianxi.model.HttpUtils; import dongyushan.bwie.com.lianxi.view.IXiangQingView; import io.reactivex.Observable; import io.reactivex.Observer; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; import io.reactivex.schedulers.Schedulers; public class XiangQingPresenter extends BasePresenter<IXiangQingView> { public void souLoadData(int pid) { final Observable<XiangQingBean> xiangqing = HttpUtils.getHttpUtilsInstance().apiClient.xiangqing(pid); xiangqing.subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Observer<XiangQingBean>() { @Override public void onSubscribe(Disposable d) { } @Override public void onNext(XiangQingBean xiangQingBean) { String title = xiangQingBean.getData().getTitle(); Log.i("aaa",title); getView().onSuccess(xiangQingBean); } @Override public void onError(Throwable e) { } @Override public void onComplete() { } }); } }
package dongyushan.bwie.com.lianxi.presenter; import android.util.Log; import dongyushan.bwie.com.lianxi.bean.CarBean; import dongyushan.bwie.com.lianxi.model.HttpUtils; import dongyushan.bwie.com.lianxi.view.IGouView; import io.reactivex.Observable; import io.reactivex.Observer; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; import io.reactivex.schedulers.Schedulers; public class CarsPresenter extends BasePresenter<IGouView> { public void GouloadDataFromNet(int uid) { Log.i("aaa",uid+""); Observable<CarBean> gouwuche = HttpUtils.getHttpUtilsInstance().apiClient.gouwuche(75); gouwuche.subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Observer<CarBean>() { @Override public void onSubscribe(Disposable d) { } @Override public void onNext(CarBean carBean) { Log.i("aaa","tianwangshishagou"); getView().onsuccer(carBean); } @Override public void onError(Throwable e) { } @Override public void onComplete() { } }); } }