ソースを参照

提交拦截器修改

皇甫睿欣 7 年 前
コミット
ed064ce26d

+ 1 - 0
laraver-core/build.gradle

@@ -82,4 +82,5 @@ dependencies {
82 82
     compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
83 83
     compile 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
84 84
 
85
+
85 86
 }

+ 12 - 1
laraver-core/src/main/java/com/kuxuan/laraver/net/RestCreator.java

@@ -2,6 +2,7 @@ package com.kuxuan.laraver.net;
2 2
 
3 3
 import com.kuxuan.laraver.app.ConfigKeys;
4 4
 import com.kuxuan.laraver.app.Laraver;
5
+import com.kuxuan.laraver.net.interceptors.ReleaseInterceptor;
5 6
 import com.kuxuan.laraver.net.rx.RxRestService;
6 7
 
7 8
 import java.util.ArrayList;
@@ -38,7 +39,17 @@ public final class RestCreator {
38 39
     private static final class OKHttpHolder {
39 40
         private static final int TIME_OUT = 60;
40 41
         private static final OkHttpClient.Builder BUILDER = new OkHttpClient.Builder();
41
-        private static final ArrayList<Interceptor> INTERCEPTORS = Laraver.getConfiguration(ConfigKeys.INTERCEPTOR);
42
+        //private static final ArrayList<Interceptor> INTERCEPTORS = Laraver.getConfiguration(ConfigKeys.INTERCEPTOR);
43
+        private static  ArrayList<Interceptor> INTERCEPTORS =null;
44
+
45
+        {
46
+            if(Laraver.getConfiguration(ConfigKeys.INTERCEPTOR)!=null){
47
+                INTERCEPTORS = Laraver.getConfiguration(ConfigKeys.INTERCEPTOR);
48
+            }else{
49
+                INTERCEPTORS = new ArrayList<>();
50
+                INTERCEPTORS.add(new ReleaseInterceptor());
51
+            }
52
+        }
42 53
 
43 54
         private static OkHttpClient.Builder addInterceptor() {
44 55
             if (INTERCEPTORS != null && !INTERCEPTORS.isEmpty()) {

+ 1 - 0
laraver-core/src/main/java/com/kuxuan/laraver/net/interceptors/ReleaseInterceptor.java

@@ -5,6 +5,7 @@ import com.kuxuan.laraver.util.storage.LaraverPreference;
5 5
 import java.io.IOException;
6 6
 
7 7
 import io.reactivex.functions.Consumer;
8
+import okhttp3.Interceptor;
8 9
 import okhttp3.Request;
9 10
 import okhttp3.Response;
10 11