更新 NetworkUtil.java
parent
cbf7f3eeea
commit
cc0afc2338
|
|
@ -26,6 +26,8 @@ public class NetworkUtil {
|
|||
private Handler handler = new Handler();
|
||||
private static final int MAX_RETRIES = 3;
|
||||
private static final long RETRY_DELAY_MS = 2000; // 重试延迟,例如2秒
|
||||
// OkHttpClient的单例
|
||||
private static OkHttpClient client = new OkHttpClient();
|
||||
|
||||
// API URL
|
||||
public NetworkUtil(Context context) {
|
||||
|
|
@ -35,10 +37,11 @@ public class NetworkUtil {
|
|||
}
|
||||
|
||||
public <T> void postRequest(T dataObject) {
|
||||
// 使用单例的OkHttpClient
|
||||
if (dataObject instanceof CallInfo) {
|
||||
postRequestWithRetry(dataObject, 0,callApiUrl);
|
||||
postRequestWithRetry(dataObject, 0, callApiUrl);
|
||||
} else if (dataObject instanceof SMSInfo) {
|
||||
postRequestWithRetry(dataObject, 0,smsApiUrl);
|
||||
postRequestWithRetry(dataObject, 0, smsApiUrl);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue