edit ServicesFactory
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Raffaele Mignone 2019-11-30 12:13:01 +01:00
parent 8dae517943
commit 8c1b0cb6a0
Signed by: norangebit
GPG Key ID: F5255658CB220573

View File

@ -5,9 +5,10 @@ import okhttp3.OkHttpClient
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
object ServicesFactory {
class ServicesFactory private constructor(
reader: PreferenceReader
) {
private val retrofit: Retrofit
private lateinit var reader: PreferenceReader //TODO
init {
val httpClient = OkHttpClient.Builder()
@ -55,5 +56,23 @@ object ServicesFactory {
val userService by lazy {
retrofit.create(UserService::class.java)
}
companion object {
@Volatile
private var INSTANCE: ServicesFactory? = null
fun getInstance(reader: PreferenceReader): ServicesFactory {
val tempInstance = INSTANCE
if (tempInstance != null)
return tempInstance
synchronized(this) {
val instance = ServicesFactory(reader)
INSTANCE = instance
return instance
}
}
}
}