Skip to content

Commit

Permalink
Added Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
TanishMoral11 committed Aug 9, 2024
1 parent 3bcec8a commit 629d7db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
7 changes: 5 additions & 2 deletions app/src/main/java/com/example/randommemes/ApiInterface.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ package com.example.randommemes
import retrofit2.Call
import retrofit2.http.GET

// Interface to define the API endpoints
interface ApiInterface {

// A GET request to the endpoint "gimme" which returns a Call object containing a response of type `responseDataclass`
@GET("gimme")
fun getData() : Call<responseDataclass>
}
fun getData(): Call<responseDataclass>
}
13 changes: 7 additions & 6 deletions app/src/main/java/com/example/randommemes/RetrofitInstance.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ import retrofit2.converter.gson.GsonConverterFactory

object RetrofitInstance {

//lazy meaning that it is not initialized until it is accessed for the first time
// Lazy initialization of Retrofit instance. It's created when accessed for the first time
private val retrofit by lazy {
Retrofit.Builder().baseUrl("https://meme-api.com/")
.addConverterFactory(GsonConverterFactory.create())
Retrofit.Builder()
.baseUrl("https://meme-api.com/") // Base URL for the API
.addConverterFactory(GsonConverterFactory.create()) // Convert JSON data to Kotlin objects using Gson
.build()
}

val apiInterface by lazy{
// Lazy initialization of the ApiInterface
val apiInterface by lazy {
retrofit.create(ApiInterface::class.java)
}

}
}

0 comments on commit 629d7db

Please sign in to comment.