package com.wasu.cs.mvp.presenter; import com.wasu.cs.mvp.IView.ILifeMvpView; import com.wasu.cs.mvp.model.BodyListDataModel; import com.wasu.module.datafetch.DataFetchListener; import com.wasu.module.datafetch.DataFetchModule; import org.json.JSONObject; /** * @Description: 生活屏数据解析类 * @Author: Danxingxi * @CreateDate: 2016/12/1 9:41 */ public class MainLifePagePresenter extends BasePresenter { /** * 获取首页数据 * @param url */ public void getLifePageData(String url){ DataFetchModule.getInstance().fetchJsonGet(url, new DataFetchListener.JsonListener() { @Override public void onJsonGet(int i, String s, JSONObject jsonObject) { if(getMvpView() == null){ return; } if(jsonObject == null){ getMvpView().getDataError(i, s); return; } BodyListDataModel bodyListDataModel = new BodyListDataModel(); bodyListDataModel.parseJson(jsonObject); if(bodyListDataModel!=null && bodyListDataModel.getBlocksList()!=null){ //获取第一行第二行的数据 int count = bodyListDataModel.getBlocksList().size(); for(int j=0;j0){ getMvpView().getDataSuccess1(data1.getLinkImagesList()); } } }); } /** * 第二排数据 */ private void getData2(String url2){ DataFetchModule.getInstance().fetchJsonGet(url2, new DataFetchListener.JsonListener() { @Override public void onJsonGet(int i, String s, JSONObject jsonObject) { if(jsonObject == null && getMvpView()!=null){ getMvpView().getDataError(i, s); return; } BodyListDataModel data2 = new BodyListDataModel(); data2.parseJson(jsonObject); if(data2.getLinkImagesList()!=null && data2.getLinkImagesList().size()>0){ getMvpView().getDataSuccess2(data2.getLinkImagesList()); } } }); } }