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: 解除绑定,释放内存");
}
}
--------------------- 

原文地址:https://www.cnblogs.com/hyhy904/p/11299086.html