From 496eff5e9bf0380253594ddf37a5743f6d250562 Mon Sep 17 00:00:00 2001 From: Clyhtsuriva Date: Sat, 20 Feb 2021 18:10:38 +0100 Subject: Intents now working for top mangas --- app/build.gradle | 1 + app/src/main/AndroidManifest.xml | 11 ++++- .../aniki/topmanga/DetailTopMangaActivity.kt | 36 +++++++++++++++ .../xyz/adjutor/aniki/topmanga/TopMangaAdapter.kt | 22 ++++++++- .../main/res/layout/activity_detail_top_manga.xml | 54 ++++++++++++++++++++++ app/src/main/res/layout/item_layout.xml | 9 ++-- app/src/main/res/values/strings.xml | 8 ++-- 7 files changed, 129 insertions(+), 12 deletions(-) create mode 100644 app/src/main/java/xyz/adjutor/aniki/topmanga/DetailTopMangaActivity.kt create mode 100644 app/src/main/res/layout/activity_detail_top_manga.xml (limited to 'app') diff --git a/app/build.gradle b/app/build.gradle index 4dd9f20..fb76368 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -34,6 +34,7 @@ android { dependencies { + //noinspection GradleDependency implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" implementation 'androidx.core:core-ktx:1.3.2' implementation 'androidx.appcompat:appcompat:1.2.0' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 105fdfd..5316b25 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,8 +1,9 @@ - + + android:theme="@style/Theme.Aniki" + tools:ignore="AllowBackup"> + + 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) : 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) : 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) + } } } diff --git a/app/src/main/res/layout/activity_detail_top_manga.xml b/app/src/main/res/layout/activity_detail_top_manga.xml new file mode 100644 index 0000000..3e74697 --- /dev/null +++ b/app/src/main/res/layout/activity_detail_top_manga.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_layout.xml b/app/src/main/res/layout/item_layout.xml index 5ef1c19..f904109 100644 --- a/app/src/main/res/layout/item_layout.xml +++ b/app/src/main/res/layout/item_layout.xml @@ -10,7 +10,6 @@ android:foreground="?selectableItemBackground" app:cardBackgroundColor="@color/black" app:cardCornerRadius="13dp"> - News Page Article Page Top Manga Page - Title - 0 - image + Title + 0 + image Image of manga Top Anime Page Top Anime - 00.00 + 00.00 \ No newline at end of file -- cgit v1.2.3