| | |
| | | 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.Site; |
| | | import cn.flightfeather.thirdapp.bean.entity.Town; |
| | | import cn.flightfeather.thirdapp.httpservice.InitDataService; |
| | | import retrofit2.Call; |
| | |
| | | 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()); |
| | | } |
| | | }); |
| | | } |