| | |
| | | |
| | | import cn.flightfeather.thirdapp.CommonApplication; |
| | | import cn.flightfeather.thirdapp.activity.SplashActivity; |
| | | import cn.flightfeather.thirdapp.bean.ChangeAdvice; |
| | | import cn.flightfeather.thirdapp.bean.ChangeEffect; |
| | | import cn.flightfeather.thirdapp.bean.City; |
| | | import cn.flightfeather.thirdapp.bean.District; |
| | | import cn.flightfeather.thirdapp.bean.Domaincatalog; |
| | | import cn.flightfeather.thirdapp.bean.Domainitem; |
| | | import cn.flightfeather.thirdapp.bean.Evaluationrule; |
| | | import cn.flightfeather.thirdapp.bean.Evaluationsubrule; |
| | | import cn.flightfeather.thirdapp.bean.Gittype; |
| | | import cn.flightfeather.thirdapp.bean.Problemtype; |
| | | import cn.flightfeather.thirdapp.bean.Province; |
| | | import cn.flightfeather.thirdapp.bean.Scense; |
| | | import cn.flightfeather.thirdapp.bean.Site; |
| | | import cn.flightfeather.thirdapp.bean.Town; |
| | | import cn.flightfeather.thirdapp.bean.entity.ChangeAdvice; |
| | | import cn.flightfeather.thirdapp.bean.entity.ChangeEffect; |
| | | import cn.flightfeather.thirdapp.bean.entity.City; |
| | | import cn.flightfeather.thirdapp.bean.entity.District; |
| | | import cn.flightfeather.thirdapp.bean.entity.Domaincatalog; |
| | | import cn.flightfeather.thirdapp.bean.entity.Domainitem; |
| | | import cn.flightfeather.thirdapp.bean.entity.Evaluationrule; |
| | | import cn.flightfeather.thirdapp.bean.entity.Evaluationsubrule; |
| | | import cn.flightfeather.thirdapp.bean.entity.Gittype; |
| | | import cn.flightfeather.thirdapp.bean.entity.Problemtype; |
| | | import cn.flightfeather.thirdapp.bean.entity.Province; |
| | | import cn.flightfeather.thirdapp.bean.entity.Scense; |
| | | import cn.flightfeather.thirdapp.bean.entity.Town; |
| | | import cn.flightfeather.thirdapp.httpservice.InitDataService; |
| | | import retrofit2.Call; |
| | | import retrofit2.Callback; |
| | |
| | | initDataService = retrofit.create(InitDataService.class); |
| | | daoSession = application.getDaoSession(); |
| | | scenseDao = daoSession.getScenseDao(); |
| | | siteDao = daoSession.getSiteDao(); |
| | | // siteDao = daoSession.getSiteDao(); |
| | | domaincatalogDao = daoSession.getDomaincatalogDao(); |
| | | domainitemDao = daoSession.getDomainitemDao(); |
| | | evaluationruleDao = daoSession.getEvaluationruleDao(); |
| | |
| | | scenseDao.insertInTx(scenseList); |
| | | System.out.println("Scense:Success"); |
| | | if (firstLoad){ |
| | | loadSite(); |
| | | loadDoainCatalog(); |
| | | } |
| | | }else if (response.errorBody()!=null){ |
| | | if (!requestAgain){ |
| | |
| | | handler.sendEmptyMessage(SplashActivity.SHOW_ERROR); |
| | | } |
| | | System.out.println("Scense:"+t.toString()); |
| | | } |
| | | }); |
| | | } |
| | | //加载全部工地详情 |
| | | private void loadSite(){ |
| | | Call<List<Site>> loadAllSite = initDataService.loadAllSite(); |
| | | loadAllSite.enqueue(new Callback<List<Site>>() { |
| | | @Override |
| | | public void onResponse(Call<List<Site>> call, Response<List<Site>> response) { |
| | | if (response.body()!=null){ |
| | | requestAgain = false; |
| | | List<Site> siteList = response.body(); |
| | | siteDao.deleteAll(); |
| | | siteDao.insertInTx(siteList); |
| | | System.out.println("Site:Success"); |
| | | if (firstLoad){ |
| | | loadDoainCatalog(); |
| | | } |
| | | }else if (response.errorBody()!=null){ |
| | | if (!requestAgain){ |
| | | requestAgain = true; |
| | | loadSite(); |
| | | }else { |
| | | handler.sendEmptyMessage(SplashActivity.SHOW_ERROR); |
| | | Toast.makeText(application, "获取工地详情数据失败", Toast.LENGTH_SHORT).show(); |
| | | } |
| | | System.out.println("Site:"+response.errorBody().toString()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(Call<List<Site>> call, Throwable t) { |
| | | if (!requestAgain){ |
| | | requestAgain = true; |
| | | loadSite(); |
| | | }else { |
| | | showNetErrorToast(); |
| | | handler.sendEmptyMessage(SplashActivity.SHOW_ERROR); |
| | | } |
| | | System.out.println("Site:"+t.toString()); |
| | | } |
| | | }); |
| | | } |