Skip to content

Commit

Permalink
1.6.1
Browse files Browse the repository at this point in the history
fix clients and instances
  • Loading branch information
A.Badakhshan committed Nov 4, 2023
1 parent c10746e commit 3fce63d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion ayannetworking/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.6.0"
versionName "1.6.1"
}

buildTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import ir.ayantech.ayannetworking.helper.AppSignatureHelper
import ir.ayantech.ayannetworking.helper.dePent
import ir.ayantech.ayannetworking.helper.getTypeOf
import ir.ayantech.ayannetworking.helper.toPrettyFormat
import ir.ayantech.ayannetworking.networking.RetrofitClient
import ir.ayantech.ayannetworking.networking.NetworkingClient
import okhttp3.OkHttpClient
import okhttp3.ResponseBody
import retrofit2.Call
Expand Down Expand Up @@ -84,19 +84,29 @@ class AyanApi(
retrofitInstance.create(ApiInterface::class.java)
}

private val retrofitInstance: Retrofit by lazy {
RetrofitClient.getInstance(
private val okHttpClient: OkHttpClient by lazy {
NetworkingClient.getOkHttpInstance(
userAgent,
defaultBaseUrl,
timeout,
setNoProxy,
hostName,
logItems,
feed,
feed
)
}

private val retrofitInstance: Retrofit by lazy {
NetworkingClient.getInstance(
okHttpClient,
defaultBaseUrl,
gson
)
}

fun cancelCalls() {
okHttpClient.dispatcher().cancelAll()
}

inline fun <reified GenericOutput> ayanCall(
ayanCallStatus: AyanCallStatus<GenericOutput>,
endPoint: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,12 @@ import retrofit2.converter.gson.GsonConverterFactory
import java.net.Proxy
import java.util.concurrent.TimeUnit

object RetrofitClient {
object NetworkingClient {

@Synchronized
fun getInstance(
userAgent: String,
okHttpClient: OkHttpClient,
defaultBaseUrl: String,
timeout: Long = 20,
setNoProxy: Boolean,
hostName: String? = null,
logItems: List<Int>? = null,
feed: Array<Int>? = null,
gson: Gson?
): Retrofit =
Retrofit.Builder()
Expand All @@ -29,10 +24,10 @@ object RetrofitClient {
else GsonConverterFactory.create(gson)
)
.baseUrl(defaultBaseUrl)
.client(getOkHttpInstance(userAgent, timeout, setNoProxy, hostName, logItems, feed))
.client(okHttpClient)
.build()

private fun getOkHttpInstance(
fun getOkHttpInstance(
userAgent: String,
timeout: Long,
setNoProxy: Boolean,
Expand Down

0 comments on commit 3fce63d

Please sign in to comment.