okhttp封装及logge拦截器:
http://blog.csdn.net/qq_40087961/article/details/78828811
,,记得要导入依赖及权限
商品详情页的model层
public class RecyclerDetailsModel {
//自己定义的方法
public void receive(String pid, final IRecyclerDetailsModel iRecyclerDetailsModel) {
String url="http://120.27.23.105/product/getProductDetail";
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("pid", pid);
OkHttpUtils.getInstance().doPost(url, hashMap, new CallBack() {
@Override
public void onSuccess(String str) {
if (str != null) {
Gson gson = new Gson();
RecyclerDetailsBean rdBean = gson.fromJson(str, RecyclerDetailsBean.class);
if (rdBean != null) {
iRecyclerDetailsModel.onSuccess(rdBean);
}
}
}
@Override
public void onFailed(String message) {
iRecyclerDetailsModel.onFailed();
}
});
}
}
商品详情页的model层的借口
public interface IRecyclerDetailsModel {
void onSuccess(RecyclerDetailsBean rdBean);
void onFailed();
}
商品详情页的view层接口
public interface IRecyclerDetailsPresenter {
void onSuccess(RecyclerDetailsBean rdBean);
void onFailed();
}
商品详情页的presenter层
public class RecyclerDetailsPresenter implements IRecyclerDetailsModel {
private RecyclerDetailsModel recyclerDetailsModel;
private IRecyclerDetailsPresenter irecyclerDetailsPresenter;
public RecyclerDetailsPresenter(IRecyclerDetailsPresenter irecyclerDetailsPresenter) {
this.irecyclerDetailsPresenter = irecyclerDetailsPresenter;
recyclerDetailsModel = new RecyclerDetailsModel();
}
public void receive(Strin