diff options
author | Clyhtsuriva <aimeric@adjutor.xyz> | 2021-02-20 18:56:42 +0100 |
---|---|---|
committer | Clyhtsuriva <aimeric@adjutor.xyz> | 2021-02-20 18:56:42 +0100 |
commit | 7c8476a2128f6c4494eaa2d0a363d8cbe3261ba6 (patch) | |
tree | 966591a50dd3672209cfac6cb9d3f28e5e6074d0 /app/src | |
parent | 7bc4fe28dd31176c50495b2f3b0ba5a51eca6d9e (diff) |
Beginning the manga api part.
Diffstat (limited to 'app/src')
8 files changed, 136 insertions, 7 deletions
diff --git a/app/src/main/java/xyz/adjutor/aniki/manga/Manga.kt b/app/src/main/java/xyz/adjutor/aniki/manga/Manga.kt new file mode 100644 index 0000000..43944c3 --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/manga/Manga.kt @@ -0,0 +1,31 @@ +package xyz.adjutor.aniki.manga + +import com.google.gson.annotations.SerializedName + +//Content of the top field from the api of manga +class Manga{ + + @SerializedName("url") + var url: String? = null + @SerializedName("title") + var title: String? = null + @SerializedName("rank") + var rank: Int? = null + @SerializedName("volumes") + var volumes: Int? = null + @SerializedName("chapters") + var chapters: Int? = null + @SerializedName("start_date") + var start_date: String? = null + @SerializedName("end_date") + var end_date: String? = null + @SerializedName("score") + var score: Float? = null + @SerializedName("image_url") + var image_url: String? = null + @SerializedName("synopsis") + var synopsis: String? = null + @SerializedName("background") + var background: String? = null + +} diff --git a/app/src/main/java/xyz/adjutor/aniki/manga/MangaAdapter.kt b/app/src/main/java/xyz/adjutor/aniki/manga/MangaAdapter.kt new file mode 100644 index 0000000..ad753e2 --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/manga/MangaAdapter.kt @@ -0,0 +1,58 @@ +@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<Manga>) : + RecyclerView.Adapter<MangaAdapter.MangaViewHolder>() { + + // 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 new file mode 100644 index 0000000..7692836 --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/manga/MangaApi.kt @@ -0,0 +1,11 @@ +package xyz.adjutor.aniki.manga + +import retrofit2.Call +import retrofit2.http.GET + +interface MangaApi { + + @GET("v3/manga") + fun getMangaData(): Call<Manga> + +}
\ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/topanime/TopAnime.kt b/app/src/main/java/xyz/adjutor/aniki/topanime/TopAnime.kt index a428841..3576e7b 100644 --- a/app/src/main/java/xyz/adjutor/aniki/topanime/TopAnime.kt +++ b/app/src/main/java/xyz/adjutor/aniki/topanime/TopAnime.kt @@ -2,7 +2,7 @@ package xyz.adjutor.aniki.topanime import com.google.gson.annotations.SerializedName -//Content of the top field from the api of top manga +//Content of the top field from the api of top anime class TopAnime{ @SerializedName("mal_id") diff --git a/app/src/main/java/xyz/adjutor/aniki/topmanga/DetailTopMangaActivity.kt b/app/src/main/java/xyz/adjutor/aniki/topmanga/DetailTopMangaActivity.kt index e97ee39..2f0d2c3 100644 --- a/app/src/main/java/xyz/adjutor/aniki/topmanga/DetailTopMangaActivity.kt +++ b/app/src/main/java/xyz/adjutor/aniki/topmanga/DetailTopMangaActivity.kt @@ -9,26 +9,29 @@ import com.bumptech.glide.request.RequestOptions 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" + private val currentMangaId = "themangaid" + private val currentMangaTitle = "themangatitle" + private val currentMangaRank = "themangarank" + private val currentMangaScore = "themangascore" + private val currentMangaImageUrl = "themangaimageurl" override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_detail_top_manga) + val mangaId = intent.getStringExtra(currentMangaId) val mangaTitle = intent.getStringExtra(currentMangaTitle) val mangaRank = intent.getStringExtra(currentMangaRank) val mangaScore = intent.getStringExtra(currentMangaScore) val mangaImage = intent.getStringExtra(currentMangaImageUrl) + val tvId: TextView = findViewById(R.id.tv_detail_id) 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) val ivImage: ImageView = findViewById(R.id.iv_detail_image) + tvId.text = mangaId tvTitle.text = mangaTitle tvRank.text = mangaRank tvScore.text = mangaScore 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 2eaf958..e46fc79 100644 --- a/app/src/main/java/xyz/adjutor/aniki/topmanga/TopMangaAdapter.kt +++ b/app/src/main/java/xyz/adjutor/aniki/topmanga/TopMangaAdapter.kt @@ -53,14 +53,16 @@ class TopMangaAdapter(val mangaList: List<TopManga>) : .apply(RequestOptions().override(400)) .into(holder.mangaImage) - //to go to a detail page of the selected manga + //to go to the detail page of the selected manga holder.cardview.setOnClickListener { + val currentMangaId = "themangaid" val currentMangaTitle = "themangatitle" val currentMangaRank = "themangarank" val currentMangaScore = "themangascore" val currentMangaImageUrl = "themangaimageurl" 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()) diff --git a/app/src/main/res/layout/activity_detail_top_manga.xml b/app/src/main/res/layout/activity_detail_top_manga.xml index 3e74697..42018ef 100644 --- a/app/src/main/res/layout/activity_detail_top_manga.xml +++ b/app/src/main/res/layout/activity_detail_top_manga.xml @@ -7,6 +7,16 @@ tools:context=".topmanga.DetailTopMangaActivity" android:background="@color/very_dark_purple"> + <TextView + android:id="@+id/tv_detail_id" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/id" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + android:textColor="@color/slightly_desaturated_magenta"/> + <ImageView android:id="@+id/iv_detail_image" android:layout_width="wrap_content" @@ -51,4 +61,16 @@ app:layout_constraintStart_toEndOf="@id/tv_detail_rank" android:textColor="@color/slightly_desaturated_magenta"/> + <TextView + android:id="@+id/tv_detail_synopsis" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/synopsis" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + android:textColor="@color/slightly_desaturated_magenta"/> + + + </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3bcd30b..03d4a0e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -15,5 +15,7 @@ <string name="top_anime_page_label">Top Anime Page</string> <string name="top_anime">Top Anime</string> <string name="score">00.00</string> + <string name="id">000000</string> + <string name="synopsis">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</string> </resources>
\ No newline at end of file |