chore: Make retrofitClient var lateinit

This commit is contained in:
Peter Vacho 2025-01-03 17:29:49 +01:00
parent 28211abe93
commit 16c7640fcd
Signed by: school
GPG key ID: 8CFC3837052871B4

View file

@ -25,29 +25,28 @@ object RetrofitClient {
private var baseUrl: String = DEFAULT_BASE_URL
private lateinit var appContext: Context
// TODO: Make this lateinit
private var retrofitClient: Retrofit? = null
private lateinit var retrofitClient: Retrofit
val authService: AuthService
get() = retrofitClient!!.create(AuthService::class.java)
get() = retrofitClient.create(AuthService::class.java)
val generalService: GeneralService
get() = retrofitClient!!.create(GeneralService::class.java)
get() = retrofitClient.create(GeneralService::class.java)
val eventsService: EventsService
get() = retrofitClient!!.create(EventsService::class.java)
get() = retrofitClient.create(EventsService::class.java)
val categoryService: CategoryService
get() = retrofitClient!!.create(CategoryService::class.java)
get() = retrofitClient.create(CategoryService::class.java)
val invitationService: InvitationsService
get() = retrofitClient!!.create(InvitationsService::class.java)
get() = retrofitClient.create(InvitationsService::class.java)
val usersService: UsersService
get() = retrofitClient!!.create(UsersService::class.java)
get() = retrofitClient.create(UsersService::class.java)
val notificationsService: NotificationService
get() = retrofitClient!!.create(NotificationService::class.java)
get() = retrofitClient.create(NotificationService::class.java)
fun initialize(context: Context) {
appContext = context
@ -117,7 +116,7 @@ object RetrofitClient {
*/
suspend fun ping() {
// This will potentially raise 503 HttpException
val responseBody = retrofitClient!!.create(GeneralService::class.java).ping()
val responseBody = retrofitClient.create(GeneralService::class.java).ping()
val responseText = responseBody.string()