| | |
| | | import com.doumee.keyCabinet.MApplication; |
| | | import com.doumee.keyCabinet.bean.DevConfigBean; |
| | | import com.doumee.keyCabinet.event.DevConfigEvent; |
| | | import com.doumee.keyCabinet.event.HeartEvent; |
| | | import com.doumee.keyCabinet.http.Apis; |
| | | import com.doumee.keyCabinet.http.param.BaseResponse; |
| | | import com.doumee.keyCabinet.http.param.DevLoginParam; |
| | |
| | | } |
| | | |
| | | private void sendPost() throws JSONException { |
| | | String url = SpUtil.getString("base_url",Apis.HTTP)+Apis.HEAT_HTTP; |
| | | RequestBaseObject<DevLoginParam> request = new RequestBaseObject<>(); |
| | | DevLoginParam param = new DevLoginParam(); |
| | | param.setDevCode(LMobileInfo.getDeviceUniqueId()); |
| | | request.setParam(param); |
| | | Gson gson = new Gson(); |
| | | String post = gson.toJson(request); |
| | | if(MApplication.getConfigBean().getShopId()==null|| |
| | | MApplication.getConfigBean().getGymId()==null){ |
| | | if(countTimer!=null){ |
| | | countTimer.start(); |
| | | } |
| | | return; |
| | | } |
| | | Map<String, String> headMap = new HashMap<>(); |
| | | headMap.put("shopId", MApplication.getConfigBean().getShopId()); |
| | | headMap.put("gymId",MApplication.getConfigBean().getGymId()); |
| | | headMap.put("Cookie",MApplication.getCookie()); |
| | | if(countTimer!=null){ |
| | | countTimer.start(); |
| | | } |
| | | OkHttpClientUtil.asynPost(url, post, headMap, new OkHttpClientUtil.IOkHttpClientCallBack() { |
| | | @Override |
| | | public void onSuccessful(String retBody) { |
| | | LogUtils.d("http==>",retBody); |
| | | Timber.tag("CountTimer==>").d("心跳 onSuccessful"); |
| | | BaseResponse<DevConfigBean> resp = GsonTools.changeGsonToBean(retBody, |
| | | new TypeToken<BaseResponse<DevConfigBean>>() {}.getType()); |
| | | if(resp!=null&&resp.getRecord()!=null){ |
| | | EventBus.getDefault().post(new DevConfigEvent(resp.getRecord())); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onError() { |
| | | Timber.tag("CountTimer==>").d("心跳 报错"); |
| | | } |
| | | }); |
| | | EventBus.getDefault().post(new HeartEvent()); |
| | | } |
| | | } |