From 16c7640fcd982c04f5e66a5b881ffe086592af22 Mon Sep 17 00:00:00 2001 From: Peter Vacho Date: Fri, 3 Jan 2025 17:29:49 +0100 Subject: [PATCH] chore: Make retrofitClient var lateinit --- .../neat_calendar/api/RetrofitClient.kt | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/p_vacho/neat_calendar/api/RetrofitClient.kt b/app/src/main/java/com/p_vacho/neat_calendar/api/RetrofitClient.kt index 4418ba5..c9de5be 100644 --- a/app/src/main/java/com/p_vacho/neat_calendar/api/RetrofitClient.kt +++ b/app/src/main/java/com/p_vacho/neat_calendar/api/RetrofitClient.kt @@ -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()