|
|
@@ -5,14 +5,19 @@ import com.google.gson.Gson;
|
|
|
import com.google.gson.GsonBuilder;
|
|
|
import com.mgtech.base_library.contextUtil.ContextUtils;
|
|
|
import com.mgtech.base_library.http.interceptor.InterceptorUtil;
|
|
|
+import com.zhy.http.okhttp.cookie.store.PersistentCookieStore;
|
|
|
|
|
|
import java.io.File;
|
|
|
+import java.net.CookieHandler;
|
|
|
+import java.net.CookieManager;
|
|
|
+import java.net.CookiePolicy;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
import io.reactivex.ObservableTransformer;
|
|
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
|
import io.reactivex.schedulers.Schedulers;
|
|
|
import okhttp3.Cache;
|
|
|
+import okhttp3.CookieJar;
|
|
|
import okhttp3.OkHttpClient;
|
|
|
import retrofit2.Retrofit;
|
|
|
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
|
|
|
@@ -35,6 +40,13 @@ public class RetrofitFactory {
|
|
|
private Retrofit mRetrofit;
|
|
|
|
|
|
private RetrofitFactory(){
|
|
|
+// CookieHandler cookieHandler = new CookieManager(new PersistentCookieStore(ContextUtils.getContext()),
|
|
|
+// CookiePolicy.ACCEPT_ALL);
|
|
|
+
|
|
|
+
|
|
|
+// CookieJar cookieJar =
|
|
|
+// new PersistentCookieJar(new SetCookieCache(), new SharedPrefsCookiePersistor(ContextUtils.getContext()));
|
|
|
+
|
|
|
//设置缓存路径
|
|
|
File httpCacheDirectory = new File(ContextUtils.getContext().getCacheDir(), "HttpCache");
|
|
|
//设置缓存 10M
|
|
|
@@ -48,6 +60,7 @@ public class RetrofitFactory {
|
|
|
.addInterceptor(InterceptorUtil.cacheInterceptor())
|
|
|
.addNetworkInterceptor(InterceptorUtil.cacheNetInterceptor())
|
|
|
.cache(cache)
|
|
|
+// .cookieJar(cookieJar)
|
|
|
.build();
|
|
|
|
|
|
Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").serializeNulls().create();
|