aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/xyz/adjutor/aniki
diff options
context:
space:
mode:
authorClyhtsuriva <aimeric@adjutor.xyz>2021-02-20 18:10:38 +0100
committerClyhtsuriva <aimeric@adjutor.xyz>2021-02-20 18:10:38 +0100
commit496eff5e9bf0380253594ddf37a5743f6d250562 (patch)
treee7c6810b52cf4dfd6e5aa86bd3fe43e1e3715288 /app/src/main/java/xyz/adjutor/aniki
parent1eb274dcaaf1ee5f79505da935afcd89856e21fd (diff)
Intents now working for top mangas
Diffstat (limited to 'app/src/main/java/xyz/adjutor/aniki')
-rw-r--r--app/src/main/java/xyz/adjutor/aniki/topmanga/DetailTopMangaActivity.kt36
-rw-r--r--app/src/main/java/xyz/adjutor/aniki/topmanga/TopMangaAdapter.kt22
2 files changed, 57 insertions, 1 deletions
diff --git a/app/src/main/java/xyz/adjutor/aniki/topmanga/DetailTopMangaActivity.kt b/app/src/main/java/xyz/adjutor/aniki/topmanga/DetailTopMangaActivity.kt
new file mode 100644
index 0000000..61c5b14
--- /dev/null
+++ b/app/src/main/java/xyz/adjutor/aniki/topmanga/DetailTopMangaActivity.kt
@@ -0,0 +1,36 @@
+package xyz.adjutor.aniki.topmanga
+
+import android.os.Bundle
+import android.widget.Button
+import android.widget.ImageView
+import android.widget.TextView
+import androidx.appcompat.app.AppCompatActivity
+import androidx.navigation.fragment.NavHostFragment.findNavController
+import androidx.navigation.fragment.findNavController
+import com.bumptech.glide.Glide
+import xyz.adjutor.aniki.R
+
+class DetailTopMangaActivity : AppCompatActivity() {
+
+ private val currentMangaTitle: String = "themangatitle"
+ val currentMangaRank: String = "themangarank"
+ val currentMangaScore: String = "themangascore"
+ val currentMangaImageUrl: String = "themangaimageurl"
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_detail_top_manga)
+
+ val mangaTitle = intent.getStringExtra(currentMangaTitle)
+ val mangaRank = intent.getStringExtra(currentMangaRank)
+ val mangaScore = intent.getStringExtra(currentMangaScore)
+
+ val tvTitle: TextView = findViewById(R.id.tv_detail_title)
+ val tvRank: TextView = findViewById(R.id.tv_detail_rank)
+ val tvScore: TextView = findViewById(R.id.tv_detail_score)
+
+ tvTitle.text = mangaTitle
+ tvRank.text = mangaRank
+ tvScore.text = mangaScore
+ }
+} \ No newline at end of file
diff --git a/app/src/main/java/xyz/adjutor/aniki/topmanga/TopMangaAdapter.kt b/app/src/main/java/xyz/adjutor/aniki/topmanga/TopMangaAdapter.kt
index f5a2bd2..2eaf958 100644
--- a/app/src/main/java/xyz/adjutor/aniki/topmanga/TopMangaAdapter.kt
+++ b/app/src/main/java/xyz/adjutor/aniki/topmanga/TopMangaAdapter.kt
@@ -2,11 +2,13 @@
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
@@ -21,6 +23,8 @@ class TopMangaAdapter(val mangaList: List<TopManga>) :
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
@@ -42,12 +46,28 @@ class TopMangaAdapter(val mangaList: List<TopManga>) :
holder.mangaTitle.text = currentManga.title
holder.mangaRank.text = currentManga.rank.toString()
holder.mangaScore.text = currentManga.score.toString()
- val image : String = currentManga.image_url.toString()
+ val image: String = currentManga.image_url.toString()
Glide
.with(holder.itemView.context)
.load(image)
.apply(RequestOptions().override(400))
.into(holder.mangaImage)
+
+ //to go to a detail page of the selected manga
+ holder.cardview.setOnClickListener {
+ val currentMangaTitle = "themangatitle"
+ val currentMangaRank = "themangarank"
+ val currentMangaScore = "themangascore"
+ val currentMangaImageUrl = "themangaimageurl"
+
+ val intent: Intent = Intent(holder.itemView.context, DetailTopMangaActivity::class.java).apply {
+ putExtra(currentMangaTitle, currentManga.title)
+ putExtra(currentMangaRank, currentManga.rank.toString())
+ putExtra(currentMangaScore, currentManga.score.toString())
+ putExtra(currentMangaImageUrl, currentManga.image_url.toString())
+ }
+ holder.itemView.context.startActivity(intent)
+ }
}
}