version:3.5
fix:第一次开机不弹窗,修复重复请求时不抛出onerror异常,修复email意外弹出 update:
This commit is contained in:
@@ -8,7 +8,6 @@ import android.util.Log;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.aoleyun.sn.BuildConfig;
|
||||
import com.aoleyun.sn.bean.AppListInfo;
|
||||
import com.aoleyun.sn.bean.Appground;
|
||||
import com.aoleyun.sn.bean.BaseResponse;
|
||||
import com.aoleyun.sn.bean.BrowserBookmarks;
|
||||
@@ -95,10 +94,8 @@ import java.util.concurrent.TimeUnit;
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.core.ObservableSource;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.functions.Function;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
import okhttp3.Cache;
|
||||
@@ -138,7 +135,7 @@ public class NetInterfaceManager {
|
||||
private static long cacheSize = 1024 * 1024 * 64;
|
||||
|
||||
public static final String HTTP_KEY = "YTM3YTAxNTJmMmZmNzkyM2E2YzIwZjlhZTc0NzNmMGI=";
|
||||
public static final String CUSTOM_REPEAT_REQ_PROTOCOL = "MY_CUSTOM_REPEAT_REQ_PROTOCOL";
|
||||
public static final String REPEAT_REQUEST_PROTOCOL = "OKHTTP_REPEAT_REQUEST_PROTOCOL";
|
||||
|
||||
private NetInterfaceManager(Context context) {
|
||||
this.mContext = context;
|
||||
@@ -154,9 +151,10 @@ public class NetInterfaceManager {
|
||||
try {
|
||||
if (requestIdsMap.size() > 0 && requestIdsMap.containsKey(requestKey)) {
|
||||
Log.e("REPEAT-REQUEST", "重复请求:" + requestKey + " Method @" + request.method() + " --- " + " URL = " + request.url());
|
||||
chain.call().cancel();
|
||||
//下面这行写了不会抛出onerror
|
||||
// chain.call().cancel();
|
||||
return new Response.Builder()
|
||||
.protocol(Protocol.get(CUSTOM_REPEAT_REQ_PROTOCOL))
|
||||
.protocol(Protocol.get(REPEAT_REQUEST_PROTOCOL))
|
||||
.request(request) //multi thread
|
||||
.build();
|
||||
}
|
||||
@@ -166,6 +164,7 @@ public class NetInterfaceManager {
|
||||
// builder.addHeader("header", jsonObject.toString());
|
||||
return chain.proceed(request);
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "intercept: " + e.getMessage());
|
||||
throw e;
|
||||
} finally {
|
||||
if (requestIdsMap.containsKey(requestKey) && requestIdsMap.containsValue(time)) {//请求任务完成删除map中的数据
|
||||
@@ -175,6 +174,7 @@ public class NetInterfaceManager {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//如果无法生存缓存文件目录,检测权限使用已经加上,检测手机是否把文件读写权限禁止了
|
||||
OkHttpClient.Builder builder = new OkHttpClient.Builder();
|
||||
builder.connectTimeout(timeOut, TimeUnit.SECONDS); // 设置连接超时时间
|
||||
@@ -561,6 +561,7 @@ public class NetInterfaceManager {
|
||||
long lastTime = mMMKV.decodeLong(GET_LOCKED_STATE_TIME, 0);
|
||||
if (System.currentTimeMillis() - TEN_MINUTE_TIME < lastTime) {
|
||||
callback.onComplete();
|
||||
Log.e(TAG, "getLockedState: " + "return");
|
||||
return;
|
||||
}
|
||||
NetInterfaceManager.getInstance()
|
||||
|
||||
Reference in New Issue
Block a user