From 5a8c22508e08b00a31c8ebb4df13d9e108d29e1f Mon Sep 17 00:00:00 2001 From: Clyhtsuriva Date: Tue, 13 Apr 2021 13:22:04 +0200 Subject: Restructuring and README update. --- app/src/main/AndroidManifest.xml | 8 +- .../main/java/xyz/adjutor/aniki/data/AnimeApi.kt | 13 -- .../main/java/xyz/adjutor/aniki/data/MangaApi.kt | 13 -- .../java/xyz/adjutor/aniki/data/SearchAnimeApi.kt | 13 -- .../java/xyz/adjutor/aniki/data/SearchMangaApi.kt | 13 -- .../java/xyz/adjutor/aniki/data/TopAnimeApi.kt | 13 -- .../java/xyz/adjutor/aniki/data/TopMangaApi.kt | 13 -- .../java/xyz/adjutor/aniki/data/anime/AnimeApi.kt | 13 ++ .../xyz/adjutor/aniki/data/anime/SearchAnimeApi.kt | 13 ++ .../xyz/adjutor/aniki/data/anime/TopAnimeApi.kt | 13 ++ .../java/xyz/adjutor/aniki/data/manga/MangaApi.kt | 13 ++ .../xyz/adjutor/aniki/data/manga/SearchMangaApi.kt | 13 ++ .../xyz/adjutor/aniki/data/manga/TopMangaApi.kt | 13 ++ .../presentation/controller/MainController.kt | 12 +- .../presentation/controller/TopMangaController.kt | 29 ++++ .../aniki/presentation/model/AnimeResponse.kt | 16 -- .../aniki/presentation/model/MangaResponse.kt | 22 --- .../aniki/presentation/model/SearchAnime.kt | 31 ---- .../presentation/model/SearchAnimeResponse.kt | 13 -- .../aniki/presentation/model/SearchManga.kt | 34 ---- .../presentation/model/SearchMangaResponse.kt | 13 -- .../adjutor/aniki/presentation/model/TopAnime.kt | 35 ---- .../aniki/presentation/model/TopAnimeResponse.kt | 13 -- .../adjutor/aniki/presentation/model/TopManga.kt | 35 ---- .../aniki/presentation/model/TopMangaResponse.kt | 13 -- .../presentation/model/anime/AnimeResponse.kt | 16 ++ .../aniki/presentation/model/anime/SearchAnime.kt | 31 ++++ .../model/anime/SearchAnimeResponse.kt | 13 ++ .../aniki/presentation/model/anime/TopAnime.kt | 35 ++++ .../presentation/model/anime/TopAnimeResponse.kt | 13 ++ .../presentation/model/manga/MangaResponse.kt | 22 +++ .../aniki/presentation/model/manga/SearchManga.kt | 34 ++++ .../model/manga/SearchMangaResponse.kt | 13 ++ .../aniki/presentation/model/manga/TopManga.kt | 36 ++++ .../presentation/model/manga/TopMangaResponse.kt | 13 ++ .../presentation/view/DetailSearchAnimeActivity.kt | 156 ----------------- .../presentation/view/DetailSearchMangaActivity.kt | 169 ------------------ .../presentation/view/DetailTopAnimeActivity.kt | 176 ------------------- .../presentation/view/DetailTopMangaActivity.kt | 193 --------------------- .../adjutor/aniki/presentation/view/HomePage.kt | 3 + .../aniki/presentation/view/MainActivity.kt | 1 + .../aniki/presentation/view/SearchAnimeAdapter.kt | 82 --------- .../aniki/presentation/view/SearchAnimePage.kt | 136 --------------- .../aniki/presentation/view/SearchMangaAdapter.kt | 84 --------- .../aniki/presentation/view/SearchMangaPage.kt | 144 --------------- .../aniki/presentation/view/TopAnimeAdapter.kt | 81 --------- .../aniki/presentation/view/TopAnimePage.kt | 176 ------------------- .../aniki/presentation/view/TopMangaAdapter.kt | 82 --------- .../aniki/presentation/view/TopMangaPage.kt | 177 ------------------- .../view/anime/DetailSearchAnimeActivity.kt | 156 +++++++++++++++++ .../view/anime/DetailTopAnimeActivity.kt | 176 +++++++++++++++++++ .../presentation/view/anime/SearchAnimeAdapter.kt | 82 +++++++++ .../presentation/view/anime/SearchAnimePage.kt | 137 +++++++++++++++ .../presentation/view/anime/TopAnimeAdapter.kt | 81 +++++++++ .../aniki/presentation/view/anime/TopAnimePage.kt | 176 +++++++++++++++++++ .../view/manga/DetailSearchMangaActivity.kt | 169 ++++++++++++++++++ .../view/manga/DetailTopMangaActivity.kt | 193 +++++++++++++++++++++ .../presentation/view/manga/SearchMangaAdapter.kt | 84 +++++++++ .../presentation/view/manga/SearchMangaPage.kt | 145 ++++++++++++++++ .../presentation/view/manga/TopMangaAdapter.kt | 82 +++++++++ .../aniki/presentation/view/manga/TopMangaPage.kt | 178 +++++++++++++++++++ .../main/res/layout/activity_detail_top_anime.xml | 2 +- .../main/res/layout/activity_detail_top_manga.xml | 2 +- app/src/main/res/layout/search_anime_page.xml | 2 +- app/src/main/res/layout/search_manga_page.xml | 2 +- app/src/main/res/layout/top_anime_page.xml | 2 +- app/src/main/res/layout/top_manga_page.xml | 2 +- app/src/main/res/navigation/nav_graph.xml | 8 +- 68 files changed, 2017 insertions(+), 1978 deletions(-) delete mode 100644 app/src/main/java/xyz/adjutor/aniki/data/AnimeApi.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/data/MangaApi.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/data/SearchAnimeApi.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/data/SearchMangaApi.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/data/TopAnimeApi.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/data/TopMangaApi.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/data/anime/AnimeApi.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/data/anime/SearchAnimeApi.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/data/anime/TopAnimeApi.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/data/manga/MangaApi.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/data/manga/SearchMangaApi.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/data/manga/TopMangaApi.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/controller/TopMangaController.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/AnimeResponse.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/MangaResponse.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/SearchAnime.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/SearchAnimeResponse.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/SearchManga.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/SearchMangaResponse.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/TopAnime.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/TopAnimeResponse.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/TopManga.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/TopMangaResponse.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/anime/AnimeResponse.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/anime/SearchAnime.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/anime/SearchAnimeResponse.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/anime/TopAnime.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/anime/TopAnimeResponse.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/manga/MangaResponse.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/manga/SearchManga.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/manga/SearchMangaResponse.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/manga/TopManga.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/manga/TopMangaResponse.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/DetailSearchAnimeActivity.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/DetailSearchMangaActivity.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/DetailTopAnimeActivity.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/DetailTopMangaActivity.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/SearchAnimeAdapter.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/SearchAnimePage.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/SearchMangaAdapter.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/SearchMangaPage.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/TopAnimeAdapter.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/TopAnimePage.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/TopMangaAdapter.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/TopMangaPage.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/anime/DetailSearchAnimeActivity.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/anime/DetailTopAnimeActivity.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/anime/SearchAnimeAdapter.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/anime/SearchAnimePage.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/anime/TopAnimeAdapter.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/anime/TopAnimePage.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/manga/DetailSearchMangaActivity.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/manga/DetailTopMangaActivity.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/manga/SearchMangaAdapter.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/manga/SearchMangaPage.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/manga/TopMangaAdapter.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/manga/TopMangaPage.kt (limited to 'app') diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 93413a4..356c924 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -14,19 +14,19 @@ android:theme="@style/Theme.Aniki" tools:ignore="AllowBackup"> - -} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/data/MangaApi.kt b/app/src/main/java/xyz/adjutor/aniki/data/MangaApi.kt deleted file mode 100644 index 699efa4..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/data/MangaApi.kt +++ /dev/null @@ -1,13 +0,0 @@ -package xyz.adjutor.aniki.data - -import retrofit2.Call -import retrofit2.http.GET -import retrofit2.http.Path -import xyz.adjutor.aniki.presentation.model.MangaResponse - -interface MangaApi { - - @GET("v3/manga/{id}") - fun getMangaData(@Path("id") id: String): Call - -} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/data/SearchAnimeApi.kt b/app/src/main/java/xyz/adjutor/aniki/data/SearchAnimeApi.kt deleted file mode 100644 index 1b0811b..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/data/SearchAnimeApi.kt +++ /dev/null @@ -1,13 +0,0 @@ -package xyz.adjutor.aniki.data - -import retrofit2.Call -import retrofit2.http.GET -import retrofit2.http.Query -import xyz.adjutor.aniki.presentation.model.SearchAnimeResponse - -interface SearchAnimeApi { - - @GET("v3/search/anime") - fun getSearchAnimeData(@Query("q") q: String): Call - -} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/data/SearchMangaApi.kt b/app/src/main/java/xyz/adjutor/aniki/data/SearchMangaApi.kt deleted file mode 100644 index 3b26c1a..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/data/SearchMangaApi.kt +++ /dev/null @@ -1,13 +0,0 @@ -package xyz.adjutor.aniki.data - -import retrofit2.Call -import retrofit2.http.GET -import retrofit2.http.Query -import xyz.adjutor.aniki.presentation.model.SearchMangaResponse - -interface SearchMangaApi { - - @GET("v3/search/manga") - fun getSearchMangaData(@Query("q") q: String): Call - -} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/data/TopAnimeApi.kt b/app/src/main/java/xyz/adjutor/aniki/data/TopAnimeApi.kt deleted file mode 100644 index 39bd78b..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/data/TopAnimeApi.kt +++ /dev/null @@ -1,13 +0,0 @@ -package xyz.adjutor.aniki.data - -import retrofit2.Call -import retrofit2.http.GET -import retrofit2.http.Path -import xyz.adjutor.aniki.presentation.model.TopAnimeResponse - -interface TopAnimeApi { - - @GET("v3/top/anime/{page}") - fun getTopAnimeData(@Path("page") page: Int): Call - -} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/data/TopMangaApi.kt b/app/src/main/java/xyz/adjutor/aniki/data/TopMangaApi.kt deleted file mode 100644 index 8edab88..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/data/TopMangaApi.kt +++ /dev/null @@ -1,13 +0,0 @@ -package xyz.adjutor.aniki.data - -import retrofit2.Call -import retrofit2.http.GET -import retrofit2.http.Path -import xyz.adjutor.aniki.presentation.model.TopMangaResponse - -interface TopMangaApi { - - @GET("v3/top/manga/{page}") - fun getTopMangaData(@Path("page") page: Int): Call - -} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/data/anime/AnimeApi.kt b/app/src/main/java/xyz/adjutor/aniki/data/anime/AnimeApi.kt new file mode 100644 index 0000000..24e5cd7 --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/data/anime/AnimeApi.kt @@ -0,0 +1,13 @@ +package xyz.adjutor.aniki.data.anime + +import retrofit2.Call +import retrofit2.http.GET +import retrofit2.http.Path +import xyz.adjutor.aniki.presentation.model.anime.AnimeResponse + +interface AnimeApi { + + @GET("v3/anime/{id}") + fun getAnimeData(@Path("id") id: String): Call + +} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/data/anime/SearchAnimeApi.kt b/app/src/main/java/xyz/adjutor/aniki/data/anime/SearchAnimeApi.kt new file mode 100644 index 0000000..9bd6b2d --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/data/anime/SearchAnimeApi.kt @@ -0,0 +1,13 @@ +package xyz.adjutor.aniki.data.anime + +import retrofit2.Call +import retrofit2.http.GET +import retrofit2.http.Query +import xyz.adjutor.aniki.presentation.model.anime.SearchAnimeResponse + +interface SearchAnimeApi { + + @GET("v3/search/anime") + fun getSearchAnimeData(@Query("q") q: String): Call + +} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/data/anime/TopAnimeApi.kt b/app/src/main/java/xyz/adjutor/aniki/data/anime/TopAnimeApi.kt new file mode 100644 index 0000000..76fd25f --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/data/anime/TopAnimeApi.kt @@ -0,0 +1,13 @@ +package xyz.adjutor.aniki.data.anime + +import retrofit2.Call +import retrofit2.http.GET +import retrofit2.http.Path +import xyz.adjutor.aniki.presentation.model.anime.TopAnimeResponse + +interface TopAnimeApi { + + @GET("v3/top/anime/{page}") + fun getTopAnimeData(@Path("page") page: Int): Call + +} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/data/manga/MangaApi.kt b/app/src/main/java/xyz/adjutor/aniki/data/manga/MangaApi.kt new file mode 100644 index 0000000..a0f8df1 --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/data/manga/MangaApi.kt @@ -0,0 +1,13 @@ +package xyz.adjutor.aniki.data.manga + +import retrofit2.Call +import retrofit2.http.GET +import retrofit2.http.Path +import xyz.adjutor.aniki.presentation.model.manga.MangaResponse + +interface MangaApi { + + @GET("v3/manga/{id}") + fun getMangaData(@Path("id") id: String): Call + +} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/data/manga/SearchMangaApi.kt b/app/src/main/java/xyz/adjutor/aniki/data/manga/SearchMangaApi.kt new file mode 100644 index 0000000..6cc2d77 --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/data/manga/SearchMangaApi.kt @@ -0,0 +1,13 @@ +package xyz.adjutor.aniki.data.manga + +import retrofit2.Call +import retrofit2.http.GET +import retrofit2.http.Query +import xyz.adjutor.aniki.presentation.model.manga.SearchMangaResponse + +interface SearchMangaApi { + + @GET("v3/search/manga") + fun getSearchMangaData(@Query("q") q: String): Call + +} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/data/manga/TopMangaApi.kt b/app/src/main/java/xyz/adjutor/aniki/data/manga/TopMangaApi.kt new file mode 100644 index 0000000..222dce3 --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/data/manga/TopMangaApi.kt @@ -0,0 +1,13 @@ +package xyz.adjutor.aniki.data.manga + +import retrofit2.Call +import retrofit2.http.GET +import retrofit2.http.Path +import xyz.adjutor.aniki.presentation.model.manga.TopMangaResponse + +interface TopMangaApi { + + @GET("v3/top/manga/{page}") + fun getTopMangaData(@Path("page") page: Int): Call + +} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/controller/MainController.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/MainController.kt index 312ecbe..133f84b 100644 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/controller/MainController.kt +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/MainController.kt @@ -1,7 +1,5 @@ package xyz.adjutor.aniki.presentation.controller -import xyz.adjutor.aniki.presentation.model.TopManga - class MainController { fun MainController() { @@ -12,15 +10,19 @@ class MainController { } - fun onItemClick(topmanga: TopManga) { + fun onButtonTopMangaClick() { } - fun onButtonTopMangaClick() { + fun onButtonTopAnimeClick() { } - fun onButtonTopAnimeClick() { + fun onButtonSearchMangaClick() { + + } + + fun onButtonSearchAnimeClick() { } diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/controller/TopMangaController.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/TopMangaController.kt new file mode 100644 index 0000000..cfee062 --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/TopMangaController.kt @@ -0,0 +1,29 @@ +package xyz.adjutor.aniki.presentation.controller + +class TopMangaController { + + fun TopMangaController() { + + } + + fun onStart() { + + } + + fun onButtonTopMangaClick() { + + } + + fun onButtonTopAnimeClick() { + + } + + fun onButtonSearchMangaClick() { + + } + + fun onButtonSearchAnimeClick() { + + } + +} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/model/AnimeResponse.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/model/AnimeResponse.kt deleted file mode 100644 index d682e3c..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/model/AnimeResponse.kt +++ /dev/null @@ -1,16 +0,0 @@ -package xyz.adjutor.aniki.presentation.model - -import com.google.gson.annotations.SerializedName - -class AnimeResponse { //only kept the infos I didn't have and that were interesting to me. - - @SerializedName("mal_id") - var mal_id: Int? = null - - @SerializedName("rank") - var rank: Int? = null //added for the search feature (detail) - - @SerializedName("synopsis") - var synopsis: String? = null - -} diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/model/MangaResponse.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/model/MangaResponse.kt deleted file mode 100644 index 4bd7f2f..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/model/MangaResponse.kt +++ /dev/null @@ -1,22 +0,0 @@ -package xyz.adjutor.aniki.presentation.model - -import com.google.gson.annotations.SerializedName - -class MangaResponse { //only kept the infos I didn't have and that were interesting to me. - - @SerializedName("mal_id") - var mal_id: Int? = null - - @SerializedName("chapters") - var chapters: Int? = null - - @SerializedName("synopsis") - var synopsis: String? = null - - @SerializedName("rank") - var rank: Int? = null //added for the search feature (detail) - - @SerializedName("background") - var background: String? = null //a bit of background story about the manga - -} diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/model/SearchAnime.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/model/SearchAnime.kt deleted file mode 100644 index df5189d..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/model/SearchAnime.kt +++ /dev/null @@ -1,31 +0,0 @@ -package xyz.adjutor.aniki.presentation.model - -import com.google.gson.annotations.SerializedName - -class SearchAnime { - - @SerializedName("mal_id") - var mal_id: Int? = null - - @SerializedName("url") - var url: String? = null - - @SerializedName("image_url") - var image_url: String? = null - - @SerializedName("title") - var title: String? = null - - @SerializedName("episodes") - var episodes: Int? = null - - @SerializedName("score") - var score: Float? = null - - @SerializedName("start_date") //we'll maybe remove this later - var start_date: String? = null - - @SerializedName("end_date") //we'll maybe remove this later - var end_date: String? = null - -} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/model/SearchAnimeResponse.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/model/SearchAnimeResponse.kt deleted file mode 100644 index 1e20e2f..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/model/SearchAnimeResponse.kt +++ /dev/null @@ -1,13 +0,0 @@ -package xyz.adjutor.aniki.presentation.model - -import com.google.gson.annotations.SerializedName - -class SearchAnimeResponse { //only kept the infos I didn't have and that were interesting to me. - - @SerializedName("results") - private lateinit var results: List - - fun getResults(): List { - return results - } -} diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/model/SearchManga.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/model/SearchManga.kt deleted file mode 100644 index c24d93c..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/model/SearchManga.kt +++ /dev/null @@ -1,34 +0,0 @@ -package xyz.adjutor.aniki.presentation.model - -import com.google.gson.annotations.SerializedName - -class SearchManga { - - @SerializedName("mal_id") - var mal_id: Int? = null - - @SerializedName("url") - var url: String? = null - - @SerializedName("image_url") - var image_url: String? = null - - @SerializedName("title") - var title: String? = null - - @SerializedName("chapters") - var chapters: Int? = null - - @SerializedName("volumes") - var volumes: Int? = null - - @SerializedName("score") - var score: Float? = null - - @SerializedName("start_date") //we'll maybe remove this later - var start_date: String? = null - - @SerializedName("end_date") //we'll maybe remove this later - var end_date: String? = null - -} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/model/SearchMangaResponse.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/model/SearchMangaResponse.kt deleted file mode 100644 index 4fe7047..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/model/SearchMangaResponse.kt +++ /dev/null @@ -1,13 +0,0 @@ -package xyz.adjutor.aniki.presentation.model - -import com.google.gson.annotations.SerializedName - -class SearchMangaResponse { //only kept the infos I didn't have and that were interesting to me. - - @SerializedName("results") - private lateinit var results: List - - fun getResults(): List { - return results - } -} diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/model/TopAnime.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/model/TopAnime.kt deleted file mode 100644 index 3cf4390..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/model/TopAnime.kt +++ /dev/null @@ -1,35 +0,0 @@ -package xyz.adjutor.aniki.presentation.model - -import com.google.gson.annotations.SerializedName - -//Content of the top field from the api of top anime -class TopAnime { - - @SerializedName("mal_id") - var mal_id: Int? = null - - @SerializedName("rank") - var rank: Int? = null - - @SerializedName("title") - var title: String? = null - - @SerializedName("url") - var url: String? = null - - @SerializedName("episodes") - var episodes: 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 - -} diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/model/TopAnimeResponse.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/model/TopAnimeResponse.kt deleted file mode 100644 index 95d39d6..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/model/TopAnimeResponse.kt +++ /dev/null @@ -1,13 +0,0 @@ -package xyz.adjutor.aniki.presentation.model - -import com.google.gson.annotations.SerializedName - -class TopAnimeResponse { - - @SerializedName("top") - var top: List? = null - - fun getResults(): List { - return top!! - } -} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/model/TopManga.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/model/TopManga.kt deleted file mode 100644 index 2e0886a..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/model/TopManga.kt +++ /dev/null @@ -1,35 +0,0 @@ -package xyz.adjutor.aniki.presentation.model - -import com.google.gson.annotations.SerializedName - -//Content of the top field from the api of top manga -class TopManga { - - @SerializedName("mal_id") - var mal_id: Int? = null - - @SerializedName("rank") - var rank: Int? = null - - @SerializedName("title") - var title: String? = null - - @SerializedName("url") - var url: String? = null - - @SerializedName("volumes") - var volumes: 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 - -} diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/model/TopMangaResponse.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/model/TopMangaResponse.kt deleted file mode 100644 index 1b0dd8f..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/model/TopMangaResponse.kt +++ /dev/null @@ -1,13 +0,0 @@ -package xyz.adjutor.aniki.presentation.model - -import com.google.gson.annotations.SerializedName - -class TopMangaResponse { - - @SerializedName("top") - private lateinit var top: List - - fun getResults(): List { - return top - } -} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/model/anime/AnimeResponse.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/model/anime/AnimeResponse.kt new file mode 100644 index 0000000..e4336ce --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/model/anime/AnimeResponse.kt @@ -0,0 +1,16 @@ +package xyz.adjutor.aniki.presentation.model.anime + +import com.google.gson.annotations.SerializedName + +class AnimeResponse { //only kept the infos I didn't have and that were interesting to me. + + @SerializedName("mal_id") + var mal_id: Int? = null + + @SerializedName("rank") + var rank: Int? = null //added for the search feature (detail) + + @SerializedName("synopsis") + var synopsis: String? = null + +} diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/model/anime/SearchAnime.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/model/anime/SearchAnime.kt new file mode 100644 index 0000000..7e4340c --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/model/anime/SearchAnime.kt @@ -0,0 +1,31 @@ +package xyz.adjutor.aniki.presentation.model.anime + +import com.google.gson.annotations.SerializedName + +class SearchAnime { + + @SerializedName("mal_id") + var mal_id: Int? = null + + @SerializedName("url") + var url: String? = null + + @SerializedName("image_url") + var image_url: String? = null + + @SerializedName("title") + var title: String? = null + + @SerializedName("episodes") + var episodes: Int? = null + + @SerializedName("score") + var score: Float? = null + + @SerializedName("start_date") //we'll maybe remove this later + var start_date: String? = null + + @SerializedName("end_date") //we'll maybe remove this later + var end_date: String? = null + +} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/model/anime/SearchAnimeResponse.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/model/anime/SearchAnimeResponse.kt new file mode 100644 index 0000000..d04aa67 --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/model/anime/SearchAnimeResponse.kt @@ -0,0 +1,13 @@ +package xyz.adjutor.aniki.presentation.model.anime + +import com.google.gson.annotations.SerializedName + +class SearchAnimeResponse { //only kept the infos I didn't have and that were interesting to me. + + @SerializedName("results") + private lateinit var results: List + + fun getResults(): List { + return results + } +} diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/model/anime/TopAnime.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/model/anime/TopAnime.kt new file mode 100644 index 0000000..aefc1c5 --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/model/anime/TopAnime.kt @@ -0,0 +1,35 @@ +package xyz.adjutor.aniki.presentation.model.anime + +import com.google.gson.annotations.SerializedName + +//Content of the top field from the api of top anime +class TopAnime { + + @SerializedName("mal_id") + var mal_id: Int? = null + + @SerializedName("rank") + var rank: Int? = null + + @SerializedName("title") + var title: String? = null + + @SerializedName("url") + var url: String? = null + + @SerializedName("episodes") + var episodes: 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 + +} diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/model/anime/TopAnimeResponse.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/model/anime/TopAnimeResponse.kt new file mode 100644 index 0000000..48e2f8f --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/model/anime/TopAnimeResponse.kt @@ -0,0 +1,13 @@ +package xyz.adjutor.aniki.presentation.model.anime + +import com.google.gson.annotations.SerializedName + +class TopAnimeResponse { + + @SerializedName("top") + var top: List? = null + + fun getResults(): List { + return top!! + } +} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/model/manga/MangaResponse.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/model/manga/MangaResponse.kt new file mode 100644 index 0000000..06aeed0 --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/model/manga/MangaResponse.kt @@ -0,0 +1,22 @@ +package xyz.adjutor.aniki.presentation.model.manga + +import com.google.gson.annotations.SerializedName + +class MangaResponse { //only kept the infos I didn't have and that were interesting to me. + + @SerializedName("mal_id") + var mal_id: Int? = null + + @SerializedName("chapters") + var chapters: Int? = null + + @SerializedName("synopsis") + var synopsis: String? = null + + @SerializedName("rank") + var rank: Int? = null //added for the search feature (detail) + + @SerializedName("background") + var background: String? = null //a bit of background story about the manga + +} diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/model/manga/SearchManga.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/model/manga/SearchManga.kt new file mode 100644 index 0000000..d69227b --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/model/manga/SearchManga.kt @@ -0,0 +1,34 @@ +package xyz.adjutor.aniki.presentation.model.manga + +import com.google.gson.annotations.SerializedName + +class SearchManga { + + @SerializedName("mal_id") + var mal_id: Int? = null + + @SerializedName("url") + var url: String? = null + + @SerializedName("image_url") + var image_url: String? = null + + @SerializedName("title") + var title: String? = null + + @SerializedName("chapters") + var chapters: Int? = null + + @SerializedName("volumes") + var volumes: Int? = null + + @SerializedName("score") + var score: Float? = null + + @SerializedName("start_date") //we'll maybe remove this later + var start_date: String? = null + + @SerializedName("end_date") //we'll maybe remove this later + var end_date: String? = null + +} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/model/manga/SearchMangaResponse.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/model/manga/SearchMangaResponse.kt new file mode 100644 index 0000000..942c071 --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/model/manga/SearchMangaResponse.kt @@ -0,0 +1,13 @@ +package xyz.adjutor.aniki.presentation.model.manga + +import com.google.gson.annotations.SerializedName + +class SearchMangaResponse { //only kept the infos I didn't have and that were interesting to me. + + @SerializedName("results") + private lateinit var results: List + + fun getResults(): List { + return results + } +} diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/model/manga/TopManga.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/model/manga/TopManga.kt new file mode 100644 index 0000000..4fe3951 --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/model/manga/TopManga.kt @@ -0,0 +1,36 @@ +package xyz.adjutor.aniki.presentation.model.manga + +import com.google.gson.annotations.SerializedName + +//model +//Content of the top field from the api of top manga +class TopManga { + + @SerializedName("mal_id") + var mal_id: Int? = null + + @SerializedName("rank") + var rank: Int? = null + + @SerializedName("title") + var title: String? = null + + @SerializedName("url") + var url: String? = null + + @SerializedName("volumes") + var volumes: 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 + +} diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/model/manga/TopMangaResponse.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/model/manga/TopMangaResponse.kt new file mode 100644 index 0000000..a0f6b8c --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/model/manga/TopMangaResponse.kt @@ -0,0 +1,13 @@ +package xyz.adjutor.aniki.presentation.model.manga + +import com.google.gson.annotations.SerializedName + +class TopMangaResponse { + + @SerializedName("top") + private lateinit var top: List + + fun getResults(): List { + return top + } +} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/view/DetailSearchAnimeActivity.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/view/DetailSearchAnimeActivity.kt deleted file mode 100644 index 68a30de..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/view/DetailSearchAnimeActivity.kt +++ /dev/null @@ -1,156 +0,0 @@ -package xyz.adjutor.aniki.presentation.view - -import android.os.Bundle -import android.widget.ImageView -import android.widget.TextView -import android.widget.Toast -import androidx.appcompat.app.AppCompatActivity -import com.bumptech.glide.Glide -import com.bumptech.glide.request.RequestOptions -import com.google.gson.GsonBuilder -import retrofit2.Call -import retrofit2.Callback -import retrofit2.Response -import retrofit2.Retrofit -import retrofit2.converter.gson.GsonConverterFactory -import xyz.adjutor.aniki.R -import xyz.adjutor.aniki.data.AnimeApi -import xyz.adjutor.aniki.presentation.model.AnimeResponse - -class DetailSearchAnimeActivity : AppCompatActivity() { - - private var baseUrl = "https://api.jikan.moe/" - private val gson = GsonBuilder() - .setLenient() - .create() - - //used in the list - private val intentAnimeImageUrl = "theanimeimageurl" - private val intentAnimeTitle = "theanimetitle" - private val intentAnimeScore = "theanimescore" - - //only used for the detail - private val intentAnimeId = "theanimeid" - private val intentAnimeUrl = "theanimeurl" - private val intentAnimeEpisodes = "theanimeepisodes" - private val intentAnimeStartDate = "theanimestartdate" - private val intentAnimeEndDate = "theanimeenddate" - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_detail_search_anime) - - val animeImageUrl = intent.getStringExtra(intentAnimeImageUrl) - val animeTitle = intent.getStringExtra(intentAnimeTitle) - val animeScore = intent.getStringExtra(intentAnimeScore) - - val animeId = intent.getStringExtra(intentAnimeId) - val animeUrl = intent.getStringExtra(intentAnimeUrl) - val animeEpisodes = intent.getStringExtra(intentAnimeEpisodes) - val animeStartDate = intent.getStringExtra(intentAnimeStartDate) - val animeEndDate = intent.getStringExtra(intentAnimeEndDate) - - - val ivImage: ImageView = findViewById(R.id.iv_detail_image) - val tvTitle: TextView = findViewById(R.id.tv_detail_title) - val tvScore: TextView = findViewById(R.id.tv_detail_score) - - val tvId: TextView = findViewById(R.id.tv_detail_id) - val tvUrl: TextView = findViewById(R.id.tv_url) - val tvEpisodes: TextView = findViewById(R.id.tv_episodes) - val tvStartDate: TextView = findViewById(R.id.tv_start_date) - val tvEndDate: TextView = findViewById(R.id.tv_end_date) - - Glide - .with(this) - .load(animeImageUrl) - .apply(RequestOptions().override(400)) - .into(ivImage) - tvTitle.text = animeTitle - tvScore.text = animeScore - - - tvId.text = animeId - tvUrl.text = animeUrl - - //using null as a string because it has been converted to a string before - tvEpisodes.text = if (animeEpisodes != "null") { - animeEpisodes - } else { - fieldIsNull() - } - - tvStartDate.text = splitDate(animeStartDate!!) - - tvEndDate.text = if (animeEndDate != "null") { - splitDate(animeEndDate!!) - } else { - fieldIsNull() - } - - makeApiCall(baseUrl, animeId.toString()) - - } - - private fun splitDate(animeDate: String): CharSequence { - val delimiter = "T" - return animeDate - .split(delimiter) //split between the date and the time - .toTypedArray()[0] //convert it to an array and take the first string - - } - - private fun makeApiCall( - BASE_URL: String, - animeId: String - ) { //we take the rest of the data that we need from the internet - - val retrofit = Retrofit.Builder() - .baseUrl(BASE_URL) - .addConverterFactory(GsonConverterFactory.create(gson)) - .build() - - val service = retrofit.create(AnimeApi::class.java) - val call = service.getAnimeData(animeId) //based on the id - - call.enqueue(object : Callback { - override fun onResponse( - call: Call, - response: Response - ) { - if (response.isSuccessful && response.body() != null) { //if the code returned is >= 200 and < 300 AND the the body ain't empty - - val anime = response.body() //getting the AnimeResponse fields - showDetail(anime!!) - - } else { - showError("API ERROR : is not successful") - } - } - - override fun onFailure(call: Call, t: Throwable) { - showError("API ERROR : onFailure") - } - - }) - } - - private fun showDetail(anime: AnimeResponse) { - //elements from AnimeResponse - val tvSynopsis: TextView = findViewById(R.id.tv_synopsis) - val tvRank: TextView = findViewById(R.id.tv_detail_rank) - - tvSynopsis.text = anime.synopsis.toString() - - tvRank.text = anime.rank.toString() - - } - - fun showError(text: String) { - Toast.makeText(this, text, Toast.LENGTH_LONG).show() - } - - private fun fieldIsNull(): String { - return "Unknown" - } -} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/view/DetailSearchMangaActivity.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/view/DetailSearchMangaActivity.kt deleted file mode 100644 index d96cc70..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/view/DetailSearchMangaActivity.kt +++ /dev/null @@ -1,169 +0,0 @@ -package xyz.adjutor.aniki.presentation.view - -import android.os.Bundle -import android.widget.ImageView -import android.widget.TextView -import android.widget.Toast -import androidx.appcompat.app.AppCompatActivity -import com.bumptech.glide.Glide -import com.bumptech.glide.request.RequestOptions -import com.google.gson.GsonBuilder -import retrofit2.Call -import retrofit2.Callback -import retrofit2.Response -import retrofit2.Retrofit -import retrofit2.converter.gson.GsonConverterFactory -import xyz.adjutor.aniki.R -import xyz.adjutor.aniki.data.MangaApi -import xyz.adjutor.aniki.presentation.model.MangaResponse - -class DetailSearchMangaActivity : AppCompatActivity() { - - private var baseUrl = "https://api.jikan.moe/" - private val gson = GsonBuilder() - .setLenient() - .create() - - //used in the list - private val intentMangaImageUrl = "themangaimageurl" - private val intentMangaTitle = "themangatitle" - private val intentMangaScore = "themangascore" - - //only used for the detail - private val intentMangaId = "themangaid" - private val intentMangaUrl = "themangaurl" - private val intentMangaChapters = "themangachapters" - private val intentMangaVolumes = "themangavolumes" - private val intentMangaStartDate = "themangastartdate" - private val intentMangaEndDate = "themangaenddate" - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_detail_search_manga) - - val mangaImageUrl = intent.getStringExtra(intentMangaImageUrl) - val mangaTitle = intent.getStringExtra(intentMangaTitle) - val mangaScore = intent.getStringExtra(intentMangaScore) - - val mangaId = intent.getStringExtra(intentMangaId) - val mangaUrl = intent.getStringExtra(intentMangaUrl) - val mangaChapters = intent.getStringExtra(intentMangaChapters) - val mangaVolumes = intent.getStringExtra(intentMangaVolumes) - val mangaStartDate = intent.getStringExtra(intentMangaStartDate) - val mangaEndDate = intent.getStringExtra(intentMangaEndDate) - - - val ivImage: ImageView = findViewById(R.id.iv_detail_image) - val tvTitle: TextView = findViewById(R.id.tv_detail_title) - val tvScore: TextView = findViewById(R.id.tv_detail_score) - - val tvId: TextView = findViewById(R.id.tv_detail_id) - val tvUrl: TextView = findViewById(R.id.tv_url) - val tvChapters: TextView = findViewById(R.id.tv_chapters) - val tvVolumes: TextView = findViewById(R.id.tv_volumes) - val tvStartDate: TextView = findViewById(R.id.tv_start_date) - val tvEndDate: TextView = findViewById(R.id.tv_end_date) - - Glide - .with(this) - .load(mangaImageUrl) - .apply(RequestOptions().override(400)) - .into(ivImage) - tvTitle.text = mangaTitle - tvScore.text = mangaScore - - - tvId.text = mangaId - tvUrl.text = mangaUrl - - //using null as a string because it has been converted to a string before - tvChapters.text = if (mangaChapters != "null") { - mangaChapters - } else { - fieldIsNull() - } - - tvVolumes.text = if (mangaVolumes != "null") { - mangaVolumes - } else { - fieldIsNull() - } - - tvStartDate.text = splitDate(mangaStartDate!!) - - tvEndDate.text = if (mangaEndDate != "null") { - splitDate(mangaEndDate!!) - } else { - fieldIsNull() - } - - makeApiCall(baseUrl, mangaId.toString()) - - } - - private fun splitDate(mangaDate: String): CharSequence { - val delimiter = "T" - return mangaDate - .split(delimiter) //split between the date and the time - .toTypedArray()[0] //convert it to an array and take the first string - - } - - private fun makeApiCall(BASE_URL: String, mangaId: String) { - - val retrofit = Retrofit.Builder() - .baseUrl(BASE_URL) - .addConverterFactory(GsonConverterFactory.create(gson)) - .build() - - val service = retrofit.create(MangaApi::class.java) - val call = service.getMangaData(mangaId) //based on the id - - call.enqueue(object : Callback { - override fun onResponse( - call: Call, - response: Response - ) { - if (response.isSuccessful && response.body() != null) { //if the code returned is >= 200 and < 300 AND the the body ain't empty - - val manga = response.body() //getting the MangaResponse fields - showDetail(manga!!) - - } else { - showError("API ERROR : is not successful") - } - } - - override fun onFailure(call: Call, t: Throwable) { - showError("API ERROR : onFailure") - } - - }) - } - - private fun showDetail(manga: MangaResponse) { - //elements from MangaResponse - val tvSynopsis: TextView = findViewById(R.id.tv_synopsis) - val tvRank: TextView = findViewById(R.id.tv_detail_rank) - val tvBackground: TextView = findViewById(R.id.tv_background) - - tvSynopsis.text = manga.synopsis.toString() - - tvRank.text = manga.rank.toString() - - tvBackground.text = if (manga.background != null) { - manga.background.toString() - } else { - fieldIsNull() - } - - } - - fun showError(text: String) { - Toast.makeText(this, text, Toast.LENGTH_LONG).show() - } - - private fun fieldIsNull(): String { - return "Unknown" - } -} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/view/DetailTopAnimeActivity.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/view/DetailTopAnimeActivity.kt deleted file mode 100644 index 3ec6ab6..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/view/DetailTopAnimeActivity.kt +++ /dev/null @@ -1,176 +0,0 @@ -package xyz.adjutor.aniki.presentation.view - -import android.content.Context -import android.content.SharedPreferences -import android.os.Bundle -import android.widget.ImageView -import android.widget.TextView -import android.widget.Toast -import androidx.appcompat.app.AppCompatActivity -import com.bumptech.glide.Glide -import com.bumptech.glide.request.RequestOptions -import com.google.gson.GsonBuilder -import com.google.gson.reflect.TypeToken -import retrofit2.Call -import retrofit2.Callback -import retrofit2.Response -import retrofit2.Retrofit -import retrofit2.converter.gson.GsonConverterFactory -import xyz.adjutor.aniki.R -import xyz.adjutor.aniki.data.AnimeApi -import xyz.adjutor.aniki.presentation.model.AnimeResponse -import java.lang.reflect.Type - -class DetailTopAnimeActivity : AppCompatActivity() { - - private var baseUrl = "https://api.jikan.moe/" - private lateinit var sharedPreferences: SharedPreferences - private val gson = GsonBuilder() - .setLenient() - .create() - - private val intentAnimeId = "theanimeid" - private val intentAnimeTitle = "theanimetitle" - private val intentAnimeRank = "theanimerank" - private val intentAnimeScore = "theanimescore" - private val intentAnimeImageUrl = "theanimeimageurl" - - private val intentAnimeEpisodes = "theanimeepisodes" - private val intentAnimeStartDate = "theanimestartdate" - private val intentAnimeEndDate = "theanimeenddate" - private val intentAnimeUrl = "theanimeurl" - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_detail_top_anime) - - sharedPreferences = this.getSharedPreferences("sp_anime", Context.MODE_PRIVATE) - - val animeId = intent.getStringExtra(intentAnimeId) - val animeTitle = intent.getStringExtra(intentAnimeTitle) - val animeRank = intent.getStringExtra(intentAnimeRank) - val animeScore = intent.getStringExtra(intentAnimeScore) - val animeImageUrl = intent.getStringExtra(intentAnimeImageUrl) - - val animeEpisodes = intent.getStringExtra(intentAnimeEpisodes) - val animeStartDate = intent.getStringExtra(intentAnimeStartDate) - val animeEndDate = intent.getStringExtra(intentAnimeEndDate) - val animeUrl = intent.getStringExtra(intentAnimeUrl) - - 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) - - val tvEpisodes: TextView = findViewById(R.id.tv_episodes) - val tvStartDate: TextView = findViewById(R.id.tv_start_date) - val tvEndDate: TextView = findViewById(R.id.tv_end_date) - val tvUrl: TextView = findViewById(R.id.tv_url) - - tvId.text = animeId - tvTitle.text = animeTitle - tvRank.text = animeRank - tvScore.text = animeScore - Glide - .with(this) - .load(animeImageUrl) - .apply(RequestOptions().override(400)) - .into(ivImage) - - //using null as a string because it has been converted to a string before - tvEpisodes.text = if (animeEpisodes != "null") { - animeEpisodes - } else { - fieldIsNull() - } - - tvStartDate.text = animeStartDate - - tvEndDate.text = if (animeEndDate != "null") { - animeEndDate - } else { - fieldIsNull() - } - - tvUrl.text = animeUrl - - val anime: AnimeResponse? = getDataFromCache(animeId.toString()) - if (anime != null) { - showDetail(anime) - } else { - //taking the API's fields I want and displaying them - makeApiCall(baseUrl, animeId.toString()) - } - - } - - private fun getDataFromCache(animeId: String): AnimeResponse? { - val jsonAnime: String? = sharedPreferences.getString(animeId, null) - - return if (jsonAnime == null) { - null - } else { - val type: Type = object : TypeToken() {}.type - gson.fromJson(jsonAnime, type) - } - } - - private fun makeApiCall(BASE_URL: String, animeId: String) { - - val retrofit = Retrofit.Builder() - .baseUrl(BASE_URL) - .addConverterFactory(GsonConverterFactory.create(gson)) - .build() - - val service = retrofit.create(AnimeApi::class.java) - val call = service.getAnimeData(animeId) //based on the id - - call.enqueue(object : Callback { - override fun onResponse( - call: Call, - response: Response - ) { - if (response.isSuccessful && response.body() != null) { //if the code returned is >= 200 and < 300 AND the the body ain't empty - - val anime = response.body() //getting the AnimeResponse fields - saveList(anime) - showDetail(anime!!) - - } else { - showError("API ERROR : is not successful") - } - } - - override fun onFailure(call: Call, t: Throwable) { - showError("API ERROR : onFailure") - } - - }) - } - - private fun showDetail(anime: AnimeResponse) { - //elements from AnimeResponse - val tvSynopsis: TextView = findViewById(R.id.tv_synopsis) - - tvSynopsis.text = anime.synopsis.toString() - - } - - fun showError(text: String) { - Toast.makeText(this, text, Toast.LENGTH_LONG).show() - } - - private fun fieldIsNull(): String { - return "Unknown" - } - - fun saveList(anime: AnimeResponse?) { - val jsonString: String = gson.toJson(anime) - - sharedPreferences - .edit() - .putString(anime?.mal_id.toString(), jsonString) - .apply() - } -} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/view/DetailTopMangaActivity.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/view/DetailTopMangaActivity.kt deleted file mode 100644 index 0142018..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/view/DetailTopMangaActivity.kt +++ /dev/null @@ -1,193 +0,0 @@ -package xyz.adjutor.aniki.presentation.view - -import android.content.Context -import android.content.SharedPreferences -import android.os.Bundle -import android.widget.ImageView -import android.widget.TextView -import android.widget.Toast -import androidx.appcompat.app.AppCompatActivity -import com.bumptech.glide.Glide -import com.bumptech.glide.request.RequestOptions -import com.google.gson.GsonBuilder -import com.google.gson.reflect.TypeToken -import retrofit2.Call -import retrofit2.Callback -import retrofit2.Response -import retrofit2.Retrofit -import retrofit2.converter.gson.GsonConverterFactory -import xyz.adjutor.aniki.R -import xyz.adjutor.aniki.data.MangaApi -import xyz.adjutor.aniki.presentation.model.MangaResponse -import java.lang.reflect.Type - -class DetailTopMangaActivity : AppCompatActivity() { - - private var baseUrl = "https://api.jikan.moe/" - private lateinit var sharedPreferences: SharedPreferences - private val gson = GsonBuilder() - .setLenient() - .create() - - //used in the list - private val intentMangaTitle = "themangatitle" - private val intentMangaRank = "themangarank" - private val intentMangaScore = "themangascore" - private val intentMangaImageUrl = "themangaimageurl" - - //only used for the detail - private val intentMangaId = "themangaid" - private val intentMangaVolumes = "themangavolumes" - private val intentMangaStartDate = "themangastartdate" - private val intentMangaEndDate = "themangaenddate" - private val intentMangaUrl = "themangaurl" - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_detail_top_manga) - - sharedPreferences = this.getSharedPreferences("sp_manga", Context.MODE_PRIVATE) - - val mangaTitle = intent.getStringExtra(intentMangaTitle) - val mangaRank = intent.getStringExtra(intentMangaRank) - val mangaScore = intent.getStringExtra(intentMangaScore) - val mangaImageUrl = intent.getStringExtra(intentMangaImageUrl) - - val mangaId = intent.getStringExtra(intentMangaId) - val mangaVolumes = intent.getStringExtra(intentMangaVolumes) - val mangaStartDate = intent.getStringExtra(intentMangaStartDate) - val mangaEndDate = intent.getStringExtra(intentMangaEndDate) - val mangaUrl = intent.getStringExtra(intentMangaUrl) - - 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) - - val tvId: TextView = findViewById(R.id.tv_detail_id) - val tvVolumes: TextView = findViewById(R.id.tv_volumes) - val tvStartDate: TextView = findViewById(R.id.tv_start_date) - val tvEndDate: TextView = findViewById(R.id.tv_end_date) - val tvUrl: TextView = findViewById(R.id.tv_url) - - tvTitle.text = mangaTitle - tvRank.text = mangaRank - tvScore.text = mangaScore - Glide - .with(this) - .load(mangaImageUrl) - .apply(RequestOptions().override(400)) - .into(ivImage) - - tvId.text = mangaId - - //using null as a string because it has been converted to a string before - tvVolumes.text = if (mangaVolumes != "null") { - mangaVolumes - } else { - fieldIsNull() - } - - tvStartDate.text = mangaStartDate - - tvEndDate.text = if (mangaEndDate != "null") { - mangaEndDate - } else { - fieldIsNull() - } - - tvUrl.text = mangaUrl - - val manga: MangaResponse? = getDataFromCache(mangaId.toString()) - if (manga != null) { - showDetail(manga) - } else { - //taking the API's fields I want and displaying them - makeApiCall(baseUrl, mangaId.toString()) - } - - } - - private fun getDataFromCache(mangaId: String): MangaResponse? { - val jsonManga: String? = sharedPreferences.getString(mangaId, null) - - return if (jsonManga == null) { - null - } else { - val type: Type = object : TypeToken() {}.type - gson.fromJson(jsonManga, type) - } - } - - private fun makeApiCall(BASE_URL: String, mangaId: String) { - - val retrofit = Retrofit.Builder() - .baseUrl(BASE_URL) - .addConverterFactory(GsonConverterFactory.create(gson)) - .build() - - val service = retrofit.create(MangaApi::class.java) - val call = service.getMangaData(mangaId) //based on the id - - call.enqueue(object : Callback { - override fun onResponse( - call: Call, - response: Response - ) { - if (response.isSuccessful && response.body() != null) { //if the code returned is >= 200 and < 300 AND the the body ain't empty - - val manga = response.body() //getting the MangaResponse fields - saveList(manga) - showDetail(manga!!) - - } else { - showError("API ERROR : is not successful") - } - } - - override fun onFailure(call: Call, t: Throwable) { - showError("API ERROR : onFailure") - } - - }) - } - - private fun showDetail(manga: MangaResponse) { - //elements from MangaResponse - val tvChapters: TextView = findViewById(R.id.tv_chapters) - val tvSynopsis: TextView = findViewById(R.id.tv_synopsis) - val tvBackground: TextView = findViewById(R.id.tv_background) - - tvChapters.text = if (manga.chapters != null) { - manga.chapters.toString() - } else { - fieldIsNull() - } - - tvSynopsis.text = manga.synopsis.toString() - - tvBackground.text = if (manga.background != null) { - manga.background.toString() - } else { - fieldIsNull() - } - - } - - fun showError(text: String) { - Toast.makeText(this, text, Toast.LENGTH_LONG).show() - } - - private fun fieldIsNull(): String { - return "Unknown" - } - - fun saveList(manga: MangaResponse?) { - val jsonString: String = gson.toJson(manga) - - sharedPreferences - .edit() - .putString(manga?.mal_id.toString(), jsonString) - .apply() - } -} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/view/HomePage.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/view/HomePage.kt index f2abca1..d740dba 100644 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/view/HomePage.kt +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/view/HomePage.kt @@ -8,9 +8,12 @@ import android.widget.Button import androidx.fragment.app.Fragment import androidx.navigation.fragment.findNavController import xyz.adjutor.aniki.R +import xyz.adjutor.aniki.presentation.controller.MainController class HomePage : Fragment() { + lateinit var controller: MainController + override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/view/MainActivity.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/view/MainActivity.kt index bff89e4..e58737a 100644 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/view/MainActivity.kt +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/view/MainActivity.kt @@ -6,6 +6,7 @@ import xyz.adjutor.aniki.R class MainActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/view/SearchAnimeAdapter.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/view/SearchAnimeAdapter.kt deleted file mode 100644 index e938473..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/view/SearchAnimeAdapter.kt +++ /dev/null @@ -1,82 +0,0 @@ -package xyz.adjutor.aniki.presentation.view - -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.presentation.model.SearchAnime - -class SearchAnimeAdapter(private val animeList: List) : - RecyclerView.Adapter() { - - // Describes an item view and its place within the RecyclerView - class AnimeViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { - val animeTitle: TextView = itemView.findViewById(R.id.tv_title) - val animeRank: TextView = itemView.findViewById(R.id.tv_rank) - val animeScore: TextView = itemView.findViewById(R.id.tv_score) - val animeImage: 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): AnimeViewHolder { - val view = LayoutInflater.from(parent.context) - .inflate(R.layout.item_layout, parent, false) - - return AnimeViewHolder(view) - } - - // Returns size of data list - override fun getItemCount(): Int { - return animeList.size - } - - // Displays data at a certain position - override fun onBindViewHolder(holder: AnimeViewHolder, position: Int) { - val currentAnime: SearchAnime = animeList[position] - holder.animeTitle.text = currentAnime.title - holder.animeRank.text = "" //the rank isn't supplied by this API - holder.animeScore.text = currentAnime.score.toString() - val image: String = currentAnime.image_url.toString() - Glide - .with(holder.itemView.context) - .load(image) - .apply(RequestOptions().override(400)) - .into(holder.animeImage) - - //when you click on a selected cardview, some datas are sent to the other activity - holder.cardview.setOnClickListener { - val currentAnimeId = "theanimeid" - val currentAnimeUrl = "theanimeurl" - val currentAnimeImageUrl = "theanimeimageurl" - val currentAnimeTitle = "theanimetitle" - val currentAnimeEpisodes = "theanimeepisodes" - val currentAnimeScore = "theanimescore" - val currentAnimeStartDate = "theanimestartdate" - val currentAnimeEndDate = "theanimeenddate" - - //intent is used to pass data to another activity - - val intent: Intent = - Intent(holder.itemView.context, DetailSearchAnimeActivity::class.java).apply { - putExtra(currentAnimeId, currentAnime.mal_id.toString()) - putExtra(currentAnimeUrl, currentAnime.url.toString()) - putExtra(currentAnimeImageUrl, currentAnime.image_url.toString()) - putExtra(currentAnimeTitle, currentAnime.title) - putExtra(currentAnimeEpisodes, currentAnime.episodes.toString()) - putExtra(currentAnimeScore, currentAnime.score.toString()) - putExtra(currentAnimeStartDate, currentAnime.start_date) - putExtra(currentAnimeEndDate, currentAnime.end_date.toString()) - } - holder.itemView.context.startActivity(intent) - } - - } -} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/view/SearchAnimePage.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/view/SearchAnimePage.kt deleted file mode 100644 index d2cf795..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/view/SearchAnimePage.kt +++ /dev/null @@ -1,136 +0,0 @@ -package xyz.adjutor.aniki.presentation.view - -import android.content.Context -import android.os.Bundle -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.view.inputmethod.EditorInfo -import android.view.inputmethod.InputMethodManager -import android.widget.Button -import android.widget.TextView -import androidx.fragment.app.Fragment -import androidx.navigation.fragment.findNavController -import androidx.recyclerview.widget.LinearLayoutManager -import androidx.recyclerview.widget.RecyclerView -import com.google.android.material.snackbar.Snackbar -import com.google.android.material.textfield.TextInputEditText -import com.google.gson.Gson -import com.google.gson.GsonBuilder -import retrofit2.Call -import retrofit2.Callback -import retrofit2.Response -import retrofit2.Retrofit -import retrofit2.converter.gson.GsonConverterFactory -import xyz.adjutor.aniki.R -import xyz.adjutor.aniki.data.SearchAnimeApi -import xyz.adjutor.aniki.presentation.model.SearchAnime -import xyz.adjutor.aniki.presentation.model.SearchAnimeResponse - -class SearchAnimePage : Fragment() { - - val gson: Gson = GsonBuilder() - .setLenient() - .create() - private var baseUrl = "https://api.jikan.moe/" //the api's base url - - override fun onCreateView( - inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? - ): View? { - // Inflate the layout for this fragment - - return inflater.inflate(R.layout.search_anime_page, container, false) - } - - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - - //button to return to the home page - view.findViewById