Mymodel
package com.example.dell.kejibeidou.dingdan.model; import com.example.dell.kejibeidou.bean.DingdanBean; import com.example.dell.kejibeidou.dingdan.persenter.DdIPersnter; import com.example.dell.kejibeidou.fenlei.Http.MyService; import com.example.dell.kejibeidou.fenlei.Http.RetrofitUtils; import rx.Observable; import rx.Observer; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers; /** * Created by DELL on 2018/4/20. */ public class DdMyModel implements DdIModel { @Override public void Info5(final DdIPersnter ddIPersnter, String uid) { RetrofitUtils retrofitUtils=new RetrofitUtils(); MyService myService = retrofitUtils.creatReq(MyService.class); Observable<DingdanBean> bean5 = myService.getBean5(uid); bean5.observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.newThread()) .subscribe(new Observer<DingdanBean>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { ddIPersnter.shibai5(e.getMessage()); } @Override public void onNext(DingdanBean dingdanBean) { ddIPersnter.chenggong5(dingdanBean); } }); } }
Mypersenter
package com.example.dell.kejibeidou.dingdan.persenter; import com.example.dell.kejibeidou.bean.DingdanBean; import com.example.dell.kejibeidou.dingdan.model.DdMyModel; import com.example.dell.kejibeidou.dingdan.view.DdIView; /** * Created by DELL on 2018/4/20. */ public class DdMyPseneter implements DdIPersnter { private DdMyModel listMyModel; private DdIView listIView; public DdMyPseneter(DdIView listIView) { this.listIView = listIView; this.listMyModel=new DdMyModel(); } @Override public void chenggong5(DingdanBean bean) { if(listIView!=null){ listIView.chenggong5(bean); } } @Override public void shibai5(String msg) { if(listIView!=null){ listIView.shibai5(msg); } } @Override public void Info5(String uid) { listMyModel.Info5(this,uid); } }