| | |
| | | import com.google.gson.JsonObject; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.hdl.hdlhttp.HxHttp; |
| | | import com.hdl.hdlhttp.HxHttpConfig; |
| | | import com.hdl.hdlhttp.utils.GsonConvert; |
| | | import com.hdl.linkpm.sdk.core.api.HDLCloudUserApi; |
| | | import com.hdl.linkpm.sdk.core.exception.HDLException; |
| | | import com.hdl.linkpm.sdk.core.interceptor.HDLSmartHeader; |
| | | import com.hdl.linkpm.sdk.core.response.HDLResponse; |
| | | import com.hdl.linkpm.sdk.utils.HDLExceptionSubmitUtils; |
| | | import com.hdl.photovoltaic.HDLApp; |
| | | import com.hdl.photovoltaic.R; |
| | | import com.hdl.photovoltaic.bean.HttpResponsePack; |
| | | import com.hdl.photovoltaic.config.AppConfigManage; |
| | | import com.hdl.photovoltaic.config.UserConfigManage; |
| | |
| | | |
| | | } |
| | | return sHttpClient; |
| | | } |
| | | |
| | | public static HDLException getException(HDLException e) { |
| | | try { |
| | | String str = TextUtils.isEmpty(getErrorSting(e.getCode())) ? e.getMsg() : getErrorSting(e.getCode()); |
| | | return new HDLException(e.getCode(), str, e.getmExtra()); |
| | | } catch (Exception exception) { |
| | | return e; |
| | | } |
| | | } |
| | | |
| | | private static String getErrorSting(int code) { |
| | | try { |
| | | switch (code) { |
| | | case 1000: |
| | | return HDLApp.getInstance().getAppLocaleContext().getString(R.string.no_network_connection); |
| | | case 1001: |
| | | return HDLApp.getInstance().getAppLocaleContext().getString(R.string.parse_error); |
| | | case 1002: |
| | | return HDLApp.getInstance().getAppLocaleContext().getString(R.string.network_error); |
| | | case 1003: |
| | | case 1004: |
| | | return HDLApp.getInstance().getAppLocaleContext().getString(R.string.ssl_error); |
| | | case 1005: |
| | | return HDLApp.getInstance().getAppLocaleContext().getString(R.string.timeout_error); |
| | | case 4: |
| | | return HDLApp.getInstance().getAppLocaleContext().getString(R.string.signature_error_log_in_again); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | |
| | | public void onFailure(HDLException e) { |
| | | HDLExceptionSubmitUtils.submit(requestUrl, "", e); |
| | | if (callBack != null) { |
| | | callBack.onFailure(e); |
| | | callBack.onFailure(getException(e)); |
| | | HdlLogLogic.print("http---回复---" + requestUrl + "\r\n" + "\"{code=\"" + e.getCode() + "," + "\"message=\"" + e.getMsg() + "}", isAddToMemory); |
| | | } |
| | | } |
| | |
| | | public void onFailure(HDLException e) { |
| | | HDLExceptionSubmitUtils.submit(requestUrl, body, e); |
| | | if (callBack != null) { |
| | | callBack.onFailure(e); |
| | | callBack.onFailure(getException(e)); |
| | | // HdlLogLogic.print("http---回复---" + requestUrl + "\r\n" + "\"{code=\"" + e.getCode() + "," + "\"message=\"" + e.getMsg() + "}", isAddToMemory); |
| | | } |
| | | } |
| | |
| | | public void onFailure(HDLException e) { |
| | | HDLExceptionSubmitUtils.submit(requestUrl, body, e); |
| | | if (callBack != null) { |
| | | callBack.onFailure(e); |
| | | callBack.onFailure(getException(e)); |
| | | // HdlLogLogic.print("http---回复---" + requestUrl + "\r\n" + "\"{code=\"" + e.getCode() + "," + "\"message=\"" + e.getMsg() + "}", isAddToMemory); |
| | | } |
| | | } |