From 9e1f3503c1a80d7e108f60f9065ae08abb7c2b3f Mon Sep 17 00:00:00 2001 From: Clyhtsuriva Date: Tue, 23 Feb 2021 14:53:15 +0100 Subject: Started README and moved the packages. --- .../xyz/adjutor/aniki/topmanga/TopMangaAdapter.kt | 79 ---------------------- 1 file changed, 79 deletions(-) delete mode 100644 app/src/main/java/xyz/adjutor/aniki/topmanga/TopMangaAdapter.kt (limited to 'app/src/main/java/xyz/adjutor/aniki/topmanga/TopMangaAdapter.kt') diff --git a/app/src/main/java/xyz/adjutor/aniki/topmanga/TopMangaAdapter.kt b/app/src/main/java/xyz/adjutor/aniki/topmanga/TopMangaAdapter.kt deleted file mode 100644 index 0396b3d..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/topmanga/TopMangaAdapter.kt +++ /dev/null @@ -1,79 +0,0 @@ -package xyz.adjutor.aniki.topmanga - -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 - -class TopMangaAdapter(private 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: TopManga = 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) - - //when you click on a selected cardview, some datas are sent to the other activity - holder.cardview.setOnClickListener { - val currentMangaId = "themangaid" - val currentMangaTitle = "themangatitle" - val currentMangaRank = "themangarank" - val currentMangaScore = "themangascore" - val currentMangaImageUrl = "themangaimageurl" - val currentMangaVolumes = "themangavolumes" - val currentMangaStartDate = "themangastartdate" - val currentMangaEndDate = "themangaenddate" - val currentMangaUrl = "themangaurl" - - val intent: Intent = Intent(holder.itemView.context, DetailTopMangaActivity::class.java).apply { - putExtra(currentMangaId, currentManga.mal_id.toString()) - putExtra(currentMangaTitle, currentManga.title) - putExtra(currentMangaRank, currentManga.rank.toString()) - putExtra(currentMangaScore, currentManga.score.toString()) - putExtra(currentMangaImageUrl, currentManga.image_url.toString()) - putExtra(currentMangaVolumes, currentManga.volumes.toString()) - putExtra(currentMangaStartDate, currentManga.start_date) - putExtra(currentMangaEndDate, currentManga.end_date.toString()) - putExtra(currentMangaUrl, currentManga.url.toString()) - } - holder.itemView.context.startActivity(intent) - } - } -} \ No newline at end of file -- cgit v1.2.3