From 17eb1d06e104bc1cd93498fe3a3eaecf14c9d734 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期四, 12 十一月 2020 13:57:35 +0800
Subject: [PATCH] 1. 修复现场整改时,问题状态是‘问题审核通过’而不是“整改未审核”的问题; 2. 修改任意拍照界面的多图片展示方式为Glide,减少内存溢出的可能性; 3. 新增图片类型枚举类,罗列原有的图片类型,并新增“铭牌”和“监测设备”; 4. 修复导航功能可能导致空指针的问题; 5. 任意拍界面新增按分类拍摄功能; 6. 修复现场整改界面打开崩溃问题;
---
app/src/main/java/cn/flightfeather/thirdapp/common/net/RetrofitFactory.kt | 45 ++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 44 insertions(+), 1 deletions(-)
diff --git a/app/src/main/java/cn/flightfeather/thirdapp/common/net/RetrofitFactory.kt b/app/src/main/java/cn/flightfeather/thirdapp/common/net/RetrofitFactory.kt
index a9169a0..0fa1d28 100644
--- a/app/src/main/java/cn/flightfeather/thirdapp/common/net/RetrofitFactory.kt
+++ b/app/src/main/java/cn/flightfeather/thirdapp/common/net/RetrofitFactory.kt
@@ -1,20 +1,54 @@
package cn.flightfeather.thirdapp.common.net
+import cn.flightfeather.thirdapp.BuildConfig
import cn.flightfeather.thirdapp.CommonApplication
+import com.google.gson.GsonBuilder
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
+import okhttp3.Interceptor
+import okhttp3.OkHttpClient
import retrofit2.Response
import retrofit2.Retrofit
+import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
+import retrofit2.converter.gson.GsonConverterFactory
+import java.util.concurrent.TimeUnit
/**
* @author riku
* Date: 2019/7/22
* 缃戠粶璇锋眰
*/
-class RetrofitFactory constructor(application: CommonApplication){
+class RetrofitFactory constructor(val application: CommonApplication){
val retrofit: Retrofit = application.retrofit
+ val retrofitImage: Retrofit = application.retrofitImage
+
+ private fun newOkHttpClient(list: List<Interceptor>): OkHttpClient =
+ OkHttpClient.Builder()
+ .connectTimeout(20 * 1000L, TimeUnit.MILLISECONDS)
+ .apply {
+ list.forEach {
+ addInterceptor(it)
+ }
+ }
+ .build()
+
+ private fun newRetrofit(mOkHttpClient: OkHttpClient): Retrofit =
+ Retrofit.Builder()
+ .apply {
+ baseUrl(application.ROOT_URL_RELEASE)
+ }
+ .addConverterFactory(
+ GsonConverterFactory.create(
+ GsonBuilder()
+ .setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
+ .create()
+ )
+ )
+ .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
+ .client(mOkHttpClient)
+ .build()
companion object {
@@ -35,5 +69,14 @@
.observeOn(AndroidSchedulers.mainThread())
.subscribe(subscriber)
}
+
+ fun withProgressListeningRetrofit(listener: NetWorkProgressListener?): Retrofit {
+ return if (listener == null) {
+ instance.retrofit
+ } else {
+ val c = instance.newOkHttpClient(listOf(NetWorkProgressInterceptor(listener)))
+ instance.newRetrofit(c)
+ }
+ }
}
}
\ No newline at end of file
--
Gitblit v1.9.3