wjc
2025-04-15 cdf49871675e42a5576f725a93eec7ca15294c6f
app/src/main/java/com/hdl/photovoltaic/internet/HttpClient.java
@@ -9,12 +9,15 @@
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;
@@ -62,6 +65,37 @@
        }
        return sHttpClient;
    }
    public static HDLException getException(HDLException e) {
        try {
            String msg = TextUtils.isEmpty(getErrorSting(e.getCode())) ? e.getMsg() : getErrorSting(e.getCode());
            return new HDLException(e.getCode(), msg, 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);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "";
    }
    /**
@@ -140,7 +174,7 @@
            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);
                }
            }
@@ -175,7 +209,7 @@
            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);
                }
            }
@@ -211,7 +245,7 @@
            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);
                }
            }