From 56f69f774bc2a7ef645169f85b89934255c29cf9 Mon Sep 17 00:00:00 2001 From: Clyhtsuriva Date: Mon, 22 Feb 2021 00:00:12 +0100 Subject: API call and display on DetailTopMangaActivity.kt Still need to find a way to call with the right ID. Rn, using the id 1 of monster as a "placeholder" --- app/src/main/java/xyz/adjutor/aniki/manga/Manga.kt | 14 ------ .../java/xyz/adjutor/aniki/manga/MangaAdapter.kt | 58 ---------------------- .../main/java/xyz/adjutor/aniki/manga/MangaApi.kt | 4 +- .../xyz/adjutor/aniki/manga/RestMangaResponse.kt | 14 ++++++ 4 files changed, 16 insertions(+), 74 deletions(-) delete mode 100644 app/src/main/java/xyz/adjutor/aniki/manga/Manga.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/manga/MangaAdapter.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/manga/RestMangaResponse.kt (limited to 'app/src/main/java/xyz/adjutor/aniki/manga') diff --git a/app/src/main/java/xyz/adjutor/aniki/manga/Manga.kt b/app/src/main/java/xyz/adjutor/aniki/manga/Manga.kt deleted file mode 100644 index baba9f5..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/manga/Manga.kt +++ /dev/null @@ -1,14 +0,0 @@ -package xyz.adjutor.aniki.manga - -import com.google.gson.annotations.SerializedName - -class Manga{ //only kept the infos I didnt have and that were interresting to me. - - @SerializedName("chapters") - var chapters: Int? = null - @SerializedName("synopsis") - var synopsis: String? = null - @SerializedName("background") - var background: String? = null //a bit of background story about the manga - -} diff --git a/app/src/main/java/xyz/adjutor/aniki/manga/MangaAdapter.kt b/app/src/main/java/xyz/adjutor/aniki/manga/MangaAdapter.kt deleted file mode 100644 index ad753e2..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/manga/MangaAdapter.kt +++ /dev/null @@ -1,58 +0,0 @@ -@file:Suppress("DEPRECATION") - -package xyz.adjutor.aniki.manga - -import android.content.Intent -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.widget.ImageView -import android.widget.TextView -import androidx.cardview.widget.CardView -import androidx.recyclerview.widget.RecyclerView -import com.bumptech.glide.Glide -import com.bumptech.glide.request.RequestOptions -import xyz.adjutor.aniki.R -import xyz.adjutor.aniki.topmanga.DetailTopMangaActivity - -class MangaAdapter(val mangaList: List) : - RecyclerView.Adapter() { - - // Describes an item view and its place within the RecyclerView - class MangaViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { - val mangaTitle: TextView = itemView.findViewById(R.id.tv_title) - val mangaRank: TextView = itemView.findViewById(R.id.tv_rank) - val mangaScore: TextView = itemView.findViewById(R.id.tv_score) - val mangaImage: ImageView = itemView.findViewById(R.id.iv_image) - val cardview: CardView = itemView.findViewById(R.id.cv_cardView) - - } - - // Returns a new ViewHolder - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MangaViewHolder { - val view = LayoutInflater.from(parent.context) - .inflate(R.layout.item_layout, parent, false) - - return MangaViewHolder(view) - } - - // Returns size of data list - override fun getItemCount(): Int { - return mangaList.size - } - - // Displays data at a certain position - override fun onBindViewHolder(holder: MangaViewHolder, position: Int) { - val currentManga: Manga = mangaList[position] - holder.mangaTitle.text = currentManga.title - holder.mangaRank.text = currentManga.rank.toString() - holder.mangaScore.text = currentManga.score.toString() - val image: String = currentManga.image_url.toString() - Glide - .with(holder.itemView.context) - .load(image) - .apply(RequestOptions().override(400)) - .into(holder.mangaImage) - } -} - 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 7692836..77304bb 100644 --- a/app/src/main/java/xyz/adjutor/aniki/manga/MangaApi.kt +++ b/app/src/main/java/xyz/adjutor/aniki/manga/MangaApi.kt @@ -5,7 +5,7 @@ import retrofit2.http.GET interface MangaApi { - @GET("v3/manga") - fun getMangaData(): Call + @GET("v3/manga/1") + fun getMangaData(): Call } \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/manga/RestMangaResponse.kt b/app/src/main/java/xyz/adjutor/aniki/manga/RestMangaResponse.kt new file mode 100644 index 0000000..7a4aff9 --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/manga/RestMangaResponse.kt @@ -0,0 +1,14 @@ +package xyz.adjutor.aniki.manga + +import com.google.gson.annotations.SerializedName + +class RestMangaResponse{ //only kept the infos I didnt have and that were interresting to me. + + @SerializedName("chapters") + var chapters: Int? = null + @SerializedName("synopsis") + var synopsis: String? = null + @SerializedName("background") + var background: String? = null //a bit of background story about the manga + +} -- cgit v1.2.3