aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/xyz/adjutor
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/xyz/adjutor')
-rw-r--r--app/src/main/java/xyz/adjutor/aniki/manga/MangaApi.kt5
-rw-r--r--app/src/main/java/xyz/adjutor/aniki/topmanga/DetailTopMangaActivity.kt47
2 files changed, 27 insertions, 25 deletions
diff --git a/app/src/main/java/xyz/adjutor/aniki/manga/MangaApi.kt b/app/src/main/java/xyz/adjutor/aniki/manga/MangaApi.kt
index 77304bb..419d510 100644
--- a/app/src/main/java/xyz/adjutor/aniki/manga/MangaApi.kt
+++ b/app/src/main/java/xyz/adjutor/aniki/manga/MangaApi.kt
@@ -2,10 +2,11 @@ package xyz.adjutor.aniki.manga
import retrofit2.Call
import retrofit2.http.GET
+import retrofit2.http.Path
interface MangaApi {
- @GET("v3/manga/1")
- fun getMangaData(): Call<RestMangaResponse>
+ @GET("v3/manga/{id}")
+ fun getMangaData(@Path("id") id: String): Call<RestMangaResponse>
} \ No newline at end of file
diff --git a/app/src/main/java/xyz/adjutor/aniki/topmanga/DetailTopMangaActivity.kt b/app/src/main/java/xyz/adjutor/aniki/topmanga/DetailTopMangaActivity.kt
index 152fe4a..b222a99 100644
--- a/app/src/main/java/xyz/adjutor/aniki/topmanga/DetailTopMangaActivity.kt
+++ b/app/src/main/java/xyz/adjutor/aniki/topmanga/DetailTopMangaActivity.kt
@@ -23,35 +23,34 @@ import xyz.adjutor.aniki.manga.RestMangaResponse
class DetailTopMangaActivity : AppCompatActivity() {
- var base_url = "https://api.jikan.moe/"
- val gson = GsonBuilder()
+ private var baseUrl = "https://api.jikan.moe/"
+ private val gson = GsonBuilder()
.setLenient()
.create()
- var manga: RestMangaResponse? = null
- private val mangaId = "themangaid"
- private val mangaTitle = "themangatitle"
- private val mangaRank = "themangarank"
- private val mangaScore = "themangascore"
- private val mangaImageUrl = "themangaimageurl"
+ private val intentMangaId = "themangaid"
+ private val intentMangaTitle = "themangatitle"
+ private val intentMangaRank = "themangarank"
+ private val intentMangaScore = "themangascore"
+ private val intentMangaImageUrl = "themangaimageurl"
- private val mangaVolumes = "themangavolumes"
- private val mangaStartDate = "themangastartdate"
- private val mangaEndDate = "themangaenddate"
+ private val intentMangaVolumes = "themangavolumes"
+ private val intentMangaStartDate = "themangastartdate"
+ private val intentMangaEndDate = "themangaenddate"
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_detail_top_manga)
- val mangaId = intent.getStringExtra(mangaId)
- val mangaTitle = intent.getStringExtra(mangaTitle)
- val mangaRank = intent.getStringExtra(mangaRank)
- val mangaScore = intent.getStringExtra(mangaScore)
- val mangaImage = intent.getStringExtra(mangaImageUrl)
+ val mangaId = intent.getStringExtra(intentMangaId)
+ val mangaTitle = intent.getStringExtra(intentMangaTitle)
+ val mangaRank = intent.getStringExtra(intentMangaRank)
+ val mangaScore = intent.getStringExtra(intentMangaScore)
+ val mangaImage = intent.getStringExtra(intentMangaImageUrl)
- val mangaVolumes = intent.getStringExtra(mangaVolumes)
- val mangaStartDate = intent.getStringExtra(mangaStartDate)
- val mangaEndDate = intent.getStringExtra(mangaEndDate)
+ val mangaVolumes = intent.getStringExtra(intentMangaVolumes)
+ val mangaStartDate = intent.getStringExtra(intentMangaStartDate)
+ val mangaEndDate = intent.getStringExtra(intentMangaEndDate)
val tvId: TextView = findViewById(R.id.tv_detail_id)
val tvTitle: TextView = findViewById(R.id.tv_detail_title)
@@ -73,14 +72,16 @@ class DetailTopMangaActivity : AppCompatActivity() {
.apply(RequestOptions().override(400))
.into(ivImage)
+ //not used in the recyclerview
tvVolumes.text = mangaVolumes
tvStartDate.text = mangaStartDate
tvEndDate.text = mangaEndDate
- makeApiCall(base_url)
+ //taking the API's fields I want and displaying them
+ makeApiCall(baseUrl, mangaId.toString())
}
- private fun makeApiCall(BASE_URL: String) {
+ private fun makeApiCall(BASE_URL: String, mangaId: String) {
val retrofit = Retrofit.Builder()
.baseUrl(BASE_URL)
@@ -88,13 +89,13 @@ class DetailTopMangaActivity : AppCompatActivity() {
.build()
val service = retrofit.create(MangaApi::class.java)
- val call = service.getMangaData()
+ val call = service.getMangaData(mangaId)
call.enqueue(object : Callback<RestMangaResponse> {
override fun onResponse(call: Call<RestMangaResponse>, response: Response<RestMangaResponse>) {
if(response.isSuccessful && response.body() != null){ //if the code returned is >= 200 and < 300 AND the the body ain't empty
- manga = response.body() //getting the RestMangaResponse fields
+ val manga = response.body() //getting the RestMangaResponse fields
showDetail(manga!!)
} else {