Android MVP


/**
* presenter 层,承担业务逻辑处理,数据源处理等
*/
public class MainPresenter extends BasePresenter<MainContract.IMainView> implements MainContract.IMainPresenter {

private MainContract.IMainModel mModel;

@Override
public void attech(IBaseView view) {
super.attech(view);
mModel = new DataModel(http://www.amjmh.com/v/);
}

@Override
public void handlerData() {
getView().showDialog();

mModel.requestBaidu(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
}

@Override
public void onResponse(Call call, Response response) throws IOException {
String content = response.body().string();
getView().succes(content);
}
});
}

@Override
public void detech() {
super.detech();
/**
* 释放内存、关闭网络请求、关闭线程等操作
*/
Log.d("==========", "detech: 解除绑定,释放内存");
}
}
--------------------- 

posted @ 2019-08-04 18:08  水至清明  阅读(95)  评论(0编辑  收藏  举报