Browse Source

提交拦截器修改

皇甫睿欣 7 years ago
parent
commit
ed064ce26d

+ 1 - 0
laraver-core/build.gradle

82
     compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
82
     compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
83
     compile 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
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
 
2
 
3
 import com.kuxuan.laraver.app.ConfigKeys;
3
 import com.kuxuan.laraver.app.ConfigKeys;
4
 import com.kuxuan.laraver.app.Laraver;
4
 import com.kuxuan.laraver.app.Laraver;
5
+import com.kuxuan.laraver.net.interceptors.ReleaseInterceptor;
5
 import com.kuxuan.laraver.net.rx.RxRestService;
6
 import com.kuxuan.laraver.net.rx.RxRestService;
6
 
7
 
7
 import java.util.ArrayList;
8
 import java.util.ArrayList;
38
     private static final class OKHttpHolder {
39
     private static final class OKHttpHolder {
39
         private static final int TIME_OUT = 60;
40
         private static final int TIME_OUT = 60;
40
         private static final OkHttpClient.Builder BUILDER = new OkHttpClient.Builder();
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
         private static OkHttpClient.Builder addInterceptor() {
54
         private static OkHttpClient.Builder addInterceptor() {
44
             if (INTERCEPTORS != null && !INTERCEPTORS.isEmpty()) {
55
             if (INTERCEPTORS != null && !INTERCEPTORS.isEmpty()) {

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

5
 import java.io.IOException;
5
 import java.io.IOException;
6
 
6
 
7
 import io.reactivex.functions.Consumer;
7
 import io.reactivex.functions.Consumer;
8
+import okhttp3.Interceptor;
8
 import okhttp3.Request;
9
 import okhttp3.Request;
9
 import okhttp3.Response;
10
 import okhttp3.Response;
10
 
11