summaryrefslogtreecommitdiff
path: root/app
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
parent1eb274dcaaf1ee5f79505da935afcd89856e21fd (diff)
Intents now working for top mangas
Diffstat (limited to 'app')
-rw-r--r--app/build.gradle1
-rw-r--r--app/src/main/AndroidManifest.xml11
-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
-rw-r--r--app/src/main/res/layout/activity_detail_top_manga.xml54
-rw-r--r--app/src/main/res/layout/item_layout.xml9
-rw-r--r--app/src/main/res/values/strings.xml8
7 files changed, 129 insertions, 12 deletions
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 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
package="xyz.adjutor.aniki">
- <uses-permission android:name="android.permission.INTERNET"/>
+ <uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
@@ -10,7 +11,12 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
- android:theme="@style/Theme.Aniki">
+ android:theme="@style/Theme.Aniki"
+ tools:ignore="AllowBackup">
+ <activity
+ android:name=".topmanga.DetailTopMangaActivity"
+ android:label="Details"
+ android:theme="@style/Theme.Aniki" />
<activity
android:name=".MainActivity"
android:label="@string/app_name"
@@ -21,6 +27,7 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
+
<meta-data
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />
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)
+ }
}
}
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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context=".topmanga.DetailTopMangaActivity"
+ android:background="@color/very_dark_purple">
+
+ <ImageView
+ android:id="@+id/iv_detail_image"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:contentDescription="@string/image"
+ android:src="@mipmap/ic_launcher"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toStartOf="@id/tv_detail_title"
+ app:layout_constraintTop_toTopOf="parent" />
+
+ <TextView
+ android:id="@+id/tv_detail_title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/title"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintEnd_toStartOf="@id/tv_detail_rank"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@id/iv_detail_image"
+ android:textColor="@color/slightly_desaturated_magenta"/>
+
+ <TextView
+ android:id="@+id/tv_detail_rank"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/rank"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintEnd_toStartOf="@id/tv_detail_score"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@id/tv_detail_title"
+ android:textColor="@color/slightly_desaturated_magenta"/>
+
+ <TextView
+ android:id="@+id/tv_detail_score"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/score"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@id/tv_detail_rank"
+ android:textColor="@color/slightly_desaturated_magenta"/>
+
+</androidx.constraintlayout.widget.ConstraintLayout> \ 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">
- <!--android:onClick="fromListToDetail"-->
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
@@ -21,7 +20,7 @@
android:id="@+id/iv_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:contentDescription="@string/rv_image"
+ android:contentDescription="@string/image"
android:src="@mipmap/ic_launcher"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
@@ -33,7 +32,7 @@
android:layout_height="match_parent"
android:layout_marginHorizontal="10sp"
android:fontFamily="@font/bangers"
- android:text="@string/rv_title"
+ android:text="@string/title"
android:textAlignment="center"
android:textColor="@color/strong_pink"
android:textSize="30sp"
@@ -46,7 +45,7 @@
android:id="@+id/tv_rank"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="@string/rv_rank"
+ android:text="@string/rank"
android:textColor="@color/slightly_desaturated_magenta"
android:textSize="20sp"
app:layout_constraintBottom_toTopOf="@id/tv_title"
@@ -57,7 +56,7 @@
android:id="@+id/tv_score"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="@string/rv_score"
+ android:text="@string/score"
android:textColor="@color/slightly_desaturated_magenta"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 0a85246..3bcd30b 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -8,12 +8,12 @@
<string name="news_page_label">News Page</string>
<string name="article_page_label">Article Page</string>
<string name="top_manga_page_label">Top Manga Page</string>
- <string name="rv_title">Title</string>
- <string name="rv_rank">0</string>
- <string name="rv_image">image</string>
+ <string name="title">Title</string>
+ <string name="rank">0</string>
+ <string name="image">image</string>
<string name="manga_image_content_description">Image of manga</string>
<string name="top_anime_page_label">Top Anime Page</string>
<string name="top_anime">Top Anime</string>
- <string name="rv_score">00.00</string>
+ <string name="score">00.00</string>
</resources> \ No newline at end of file