From 8ede9457fd21ac5e272e73f5ece1d4bc9c23faab Mon Sep 17 00:00:00 2001 From: Clyhtsuriva Date: Wed, 19 May 2021 10:07:23 +0200 Subject: Big update Restructuring the packages and adding a Constants.kt for the api URL. Also adding gson in Singletons.kt --- .../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 --- .../xyz/adjutor/aniki/presentation/Constants.kt | 8 ++ .../xyz/adjutor/aniki/presentation/Singletons.kt | 25 ++-- .../controller/DetailSearchAnimeController.kt | 48 ++++++++ .../controller/DetailSearchMangaController.kt | 48 ++++++++ .../controller/DetailTopAnimeController.kt | 83 +++++++++++++ .../controller/DetailTopMangaController.kt | 83 +++++++++++++ .../controller/SearchAnimeController.kt | 57 +++++++++ .../controller/SearchMangaController.kt | 57 +++++++++ .../presentation/controller/TopAnimeController.kt | 117 +++++++++++++++++++ .../presentation/controller/TopMangaController.kt | 117 +++++++++++++++++++ .../anime/DetailSearchAnimeController.kt | 56 --------- .../controller/anime/DetailTopAnimeController.kt | 90 -------------- .../controller/anime/SearchAnimeController.kt | 65 ----------- .../controller/anime/TopAnimeController.kt | 124 -------------------- .../manga/DetailSearchMangaController.kt | 56 --------- .../controller/manga/DetailTopMangaController.kt | 90 -------------- .../controller/manga/SearchMangaController.kt | 65 ----------- .../controller/manga/TopMangaController.kt | 124 -------------------- .../aniki/presentation/model/SearchAnime.kt | 31 +++++ .../aniki/presentation/model/SearchManga.kt | 34 ++++++ .../adjutor/aniki/presentation/model/TopAnime.kt | 35 ++++++ .../adjutor/aniki/presentation/model/TopManga.kt | 36 ++++++ .../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/model/response/AnimeResponse.kt | 16 +++ .../presentation/model/response/MangaResponse.kt | 22 ++++ .../model/response/SearchAnimeResponse.kt | 14 +++ .../model/response/SearchMangaResponse.kt | 14 +++ .../model/response/TopAnimeResponse.kt | 14 +++ .../model/response/TopMangaResponse.kt | 14 +++ .../adjutor/aniki/presentation/view/HomePage.kt | 38 ------ .../aniki/presentation/view/MainActivity.kt | 15 --- .../view/activity/DetailSearchAnimeActivity.kt | 114 ++++++++++++++++++ .../view/activity/DetailSearchMangaActivity.kt | 130 +++++++++++++++++++++ .../view/activity/DetailTopAnimeActivity.kt | 104 +++++++++++++++++ .../view/activity/DetailTopMangaActivity.kt | 121 +++++++++++++++++++ .../presentation/view/activity/MainActivity.kt | 15 +++ .../view/adapter/SearchAnimeAdapter.kt | 83 +++++++++++++ .../view/adapter/SearchMangaAdapter.kt | 85 ++++++++++++++ .../presentation/view/adapter/TopAnimeAdapter.kt | 82 +++++++++++++ .../presentation/view/adapter/TopMangaAdapter.kt | 83 +++++++++++++ .../view/anime/DetailSearchAnimeActivity.kt | 114 ------------------ .../view/anime/DetailTopAnimeActivity.kt | 104 ----------------- .../presentation/view/anime/SearchAnimeAdapter.kt | 82 ------------- .../presentation/view/anime/SearchAnimePage.kt | 99 ---------------- .../presentation/view/anime/TopAnimeAdapter.kt | 81 ------------- .../aniki/presentation/view/anime/TopAnimePage.kt | 87 -------------- .../aniki/presentation/view/fragment/HomePage.kt | 38 ++++++ .../view/fragment/SearchAnimeFragment.kt | 101 ++++++++++++++++ .../view/fragment/SearchMangaFragment.kt | 102 ++++++++++++++++ .../presentation/view/fragment/TopAnimeFragment.kt | 88 ++++++++++++++ .../presentation/view/fragment/TopMangaFragment.kt | 88 ++++++++++++++ .../view/manga/DetailSearchMangaActivity.kt | 130 --------------------- .../view/manga/DetailTopMangaActivity.kt | 121 ------------------- .../presentation/view/manga/SearchMangaAdapter.kt | 84 ------------- .../presentation/view/manga/SearchMangaPage.kt | 101 ---------------- .../presentation/view/manga/TopMangaAdapter.kt | 82 ------------- .../aniki/presentation/view/manga/TopMangaPage.kt | 87 -------------- 78 files changed, 2171 insertions(+), 2213 deletions(-) create mode 100644 app/src/main/java/xyz/adjutor/aniki/data/AnimeApi.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/data/MangaApi.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/data/SearchAnimeApi.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/data/SearchMangaApi.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/data/TopAnimeApi.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/data/TopMangaApi.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/data/anime/AnimeApi.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/data/anime/SearchAnimeApi.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/data/anime/TopAnimeApi.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/data/manga/MangaApi.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/data/manga/SearchMangaApi.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/data/manga/TopMangaApi.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/Constants.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/controller/DetailSearchAnimeController.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/controller/DetailSearchMangaController.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/controller/DetailTopAnimeController.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/controller/DetailTopMangaController.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/controller/SearchAnimeController.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/controller/SearchMangaController.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/controller/TopAnimeController.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/controller/anime/DetailSearchAnimeController.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/controller/anime/DetailTopAnimeController.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/controller/anime/SearchAnimeController.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/controller/anime/TopAnimeController.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/controller/manga/DetailSearchMangaController.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/controller/manga/DetailTopMangaController.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/controller/manga/SearchMangaController.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/controller/manga/TopMangaController.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/SearchAnime.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/SearchManga.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/TopAnime.kt create 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/anime/AnimeResponse.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/anime/SearchAnime.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/anime/SearchAnimeResponse.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/anime/TopAnime.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/anime/TopAnimeResponse.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/manga/MangaResponse.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/manga/SearchManga.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/manga/SearchMangaResponse.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/manga/TopManga.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/manga/TopMangaResponse.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/response/AnimeResponse.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/response/MangaResponse.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/response/SearchAnimeResponse.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/response/SearchMangaResponse.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/response/TopAnimeResponse.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/model/response/TopMangaResponse.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/HomePage.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/MainActivity.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/activity/DetailSearchAnimeActivity.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/activity/DetailSearchMangaActivity.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/activity/DetailTopAnimeActivity.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/activity/DetailTopMangaActivity.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/activity/MainActivity.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/adapter/SearchAnimeAdapter.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/adapter/SearchMangaAdapter.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/adapter/TopAnimeAdapter.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/adapter/TopMangaAdapter.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/anime/DetailSearchAnimeActivity.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/anime/DetailTopAnimeActivity.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/anime/SearchAnimeAdapter.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/anime/SearchAnimePage.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/anime/TopAnimeAdapter.kt delete 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/fragment/HomePage.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/fragment/SearchAnimeFragment.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/fragment/SearchMangaFragment.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/fragment/TopAnimeFragment.kt create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/fragment/TopMangaFragment.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/manga/DetailSearchMangaActivity.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/manga/DetailTopMangaActivity.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/manga/SearchMangaAdapter.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/manga/SearchMangaPage.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/manga/TopMangaAdapter.kt delete mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/view/manga/TopMangaPage.kt (limited to 'app/src/main/java/xyz/adjutor/aniki') diff --git a/app/src/main/java/xyz/adjutor/aniki/data/AnimeApi.kt b/app/src/main/java/xyz/adjutor/aniki/data/AnimeApi.kt new file mode 100644 index 0000000..0f0cb17 --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/data/AnimeApi.kt @@ -0,0 +1,13 @@ +package xyz.adjutor.aniki.data + +import retrofit2.Call +import retrofit2.http.GET +import retrofit2.http.Path +import xyz.adjutor.aniki.presentation.model.response.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/MangaApi.kt b/app/src/main/java/xyz/adjutor/aniki/data/MangaApi.kt new file mode 100644 index 0000000..c6236b4 --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/data/MangaApi.kt @@ -0,0 +1,13 @@ +package xyz.adjutor.aniki.data + +import retrofit2.Call +import retrofit2.http.GET +import retrofit2.http.Path +import xyz.adjutor.aniki.presentation.model.response.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 new file mode 100644 index 0000000..6ff1439 --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/data/SearchAnimeApi.kt @@ -0,0 +1,13 @@ +package xyz.adjutor.aniki.data + +import retrofit2.Call +import retrofit2.http.GET +import retrofit2.http.Query +import xyz.adjutor.aniki.presentation.model.response.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 new file mode 100644 index 0000000..6b679b7 --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/data/SearchMangaApi.kt @@ -0,0 +1,13 @@ +package xyz.adjutor.aniki.data + +import retrofit2.Call +import retrofit2.http.GET +import retrofit2.http.Query +import xyz.adjutor.aniki.presentation.model.response.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 new file mode 100644 index 0000000..d850c2a --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/data/TopAnimeApi.kt @@ -0,0 +1,13 @@ +package xyz.adjutor.aniki.data + +import retrofit2.Call +import retrofit2.http.GET +import retrofit2.http.Path +import xyz.adjutor.aniki.presentation.model.response.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 new file mode 100644 index 0000000..c9bb53b --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/data/TopMangaApi.kt @@ -0,0 +1,13 @@ +package xyz.adjutor.aniki.data + +import retrofit2.Call +import retrofit2.http.GET +import retrofit2.http.Path +import xyz.adjutor.aniki.presentation.model.response.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 deleted file mode 100644 index 24e5cd7..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/data/anime/AnimeApi.kt +++ /dev/null @@ -1,13 +0,0 @@ -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 deleted file mode 100644 index 9bd6b2d..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/data/anime/SearchAnimeApi.kt +++ /dev/null @@ -1,13 +0,0 @@ -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 deleted file mode 100644 index 76fd25f..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/data/anime/TopAnimeApi.kt +++ /dev/null @@ -1,13 +0,0 @@ -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 deleted file mode 100644 index a0f8df1..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/data/manga/MangaApi.kt +++ /dev/null @@ -1,13 +0,0 @@ -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 deleted file mode 100644 index 6cc2d77..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/data/manga/SearchMangaApi.kt +++ /dev/null @@ -1,13 +0,0 @@ -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 deleted file mode 100644 index 222dce3..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/data/manga/TopMangaApi.kt +++ /dev/null @@ -1,13 +0,0 @@ -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/Constants.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/Constants.kt new file mode 100644 index 0000000..23e5c3f --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/Constants.kt @@ -0,0 +1,8 @@ +package xyz.adjutor.aniki.presentation + +class Constants { + companion object { + const val baseUrl = "https://api.jikan.moe/" + } + +} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/Singletons.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/Singletons.kt index 827c7e3..896757c 100644 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/Singletons.kt +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/Singletons.kt @@ -4,55 +4,52 @@ import com.google.gson.Gson import com.google.gson.GsonBuilder import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory -import xyz.adjutor.aniki.data.anime.AnimeApi -import xyz.adjutor.aniki.data.anime.SearchAnimeApi -import xyz.adjutor.aniki.data.anime.TopAnimeApi -import xyz.adjutor.aniki.data.manga.MangaApi -import xyz.adjutor.aniki.data.manga.SearchMangaApi -import xyz.adjutor.aniki.data.manga.TopMangaApi +import xyz.adjutor.aniki.data.* +import xyz.adjutor.aniki.presentation.Constants.Companion.baseUrl class Singletons { companion object { + val gson: Gson = GsonBuilder() .setLenient() - .create()!! - private const val BASE_URL = "https://api.jikan.moe/" + .create() val topMangaApi: TopMangaApi = Retrofit.Builder() - .baseUrl(BASE_URL) + .baseUrl(baseUrl) .addConverterFactory(GsonConverterFactory.create(gson)) .build() .create(TopMangaApi::class.java) val searchMangaApi: SearchMangaApi = Retrofit.Builder() - .baseUrl(BASE_URL) + .baseUrl(baseUrl) .addConverterFactory(GsonConverterFactory.create(gson)) .build() .create(SearchMangaApi::class.java) val mangaApi: MangaApi = Retrofit.Builder() - .baseUrl(BASE_URL) + .baseUrl(baseUrl) .addConverterFactory(GsonConverterFactory.create(gson)) .build() .create(MangaApi::class.java) val topAnimeApi: TopAnimeApi = Retrofit.Builder() - .baseUrl(BASE_URL) + .baseUrl(baseUrl) .addConverterFactory(GsonConverterFactory.create(gson)) .build() .create(TopAnimeApi::class.java) val searchAnimeApi: SearchAnimeApi = Retrofit.Builder() - .baseUrl(BASE_URL) + .baseUrl(baseUrl) .addConverterFactory(GsonConverterFactory.create(gson)) .build() .create(SearchAnimeApi::class.java) val animeApi: AnimeApi = Retrofit.Builder() - .baseUrl(BASE_URL) + .baseUrl(baseUrl) .addConverterFactory(GsonConverterFactory.create(gson)) .build() .create(AnimeApi::class.java) } + } diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/controller/DetailSearchAnimeController.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/DetailSearchAnimeController.kt new file mode 100644 index 0000000..95aabec --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/DetailSearchAnimeController.kt @@ -0,0 +1,48 @@ +package xyz.adjutor.aniki.presentation.controller + +import retrofit2.Call +import retrofit2.Callback +import retrofit2.Response +import xyz.adjutor.aniki.presentation.Singletons +import xyz.adjutor.aniki.presentation.model.response.AnimeResponse +import xyz.adjutor.aniki.presentation.view.activity.DetailSearchAnimeActivity + +class DetailSearchAnimeController { + + lateinit var view: DetailSearchAnimeActivity + + fun onStart(DetailSearchAnimeActivity: DetailSearchAnimeActivity, animeId: String) { + + view = DetailSearchAnimeActivity + + makeApiCall(animeId) + } + + private fun makeApiCall(animeId: String) { + + Singletons + .animeApi + .getAnimeData(animeId) //based on the id + .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 + view.showDetail(anime!!) + + } else { + view.showError("API ERROR : is not successful") + } + } + + override fun onFailure(call: Call, t: Throwable) { + view.showError("API ERROR : onFailure") + } + + }) + } + +} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/controller/DetailSearchMangaController.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/DetailSearchMangaController.kt new file mode 100644 index 0000000..d2f718a --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/DetailSearchMangaController.kt @@ -0,0 +1,48 @@ +package xyz.adjutor.aniki.presentation.controller + +import retrofit2.Call +import retrofit2.Callback +import retrofit2.Response +import xyz.adjutor.aniki.presentation.Singletons +import xyz.adjutor.aniki.presentation.model.response.MangaResponse +import xyz.adjutor.aniki.presentation.view.activity.DetailSearchMangaActivity + +class DetailSearchMangaController { + + lateinit var view: DetailSearchMangaActivity + + fun onStart(DetailSearchMangaActivity: DetailSearchMangaActivity, mangaId: String) { + + view = DetailSearchMangaActivity + + makeApiCall(mangaId) + } + + private fun makeApiCall(mangaId: String) { + + Singletons + .mangaApi + .getMangaData(mangaId) //based on the id + .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 + view.showDetail(manga!!) + + } else { + view.showError("API ERROR : is not successful") + } + } + + override fun onFailure(call: Call, t: Throwable) { + view.showError("API ERROR : onFailure") + } + + }) + } + +} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/controller/DetailTopAnimeController.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/DetailTopAnimeController.kt new file mode 100644 index 0000000..46e7edd --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/DetailTopAnimeController.kt @@ -0,0 +1,83 @@ +package xyz.adjutor.aniki.presentation.controller + +import android.content.Context +import android.content.SharedPreferences +import com.google.gson.reflect.TypeToken +import retrofit2.Call +import retrofit2.Callback +import retrofit2.Response +import xyz.adjutor.aniki.presentation.Singletons +import xyz.adjutor.aniki.presentation.Singletons.Companion.gson +import xyz.adjutor.aniki.presentation.model.response.AnimeResponse +import xyz.adjutor.aniki.presentation.view.activity.DetailTopAnimeActivity +import java.lang.reflect.Type + +class DetailTopAnimeController { + + private lateinit var sharedPreferences: SharedPreferences + lateinit var view: DetailTopAnimeActivity + + fun onStart(DetailTopAnimeActivity: DetailTopAnimeActivity, animeId: String) { + + view = DetailTopAnimeActivity + sharedPreferences = + view.applicationContext.getSharedPreferences("sp_anime", Context.MODE_PRIVATE) + + val anime: AnimeResponse? = getDataFromCache(animeId) + if (anime != null) { + view.showDetail(anime) + } else { + //taking the API's fields I want and displaying them + makeApiCall(animeId) + } + } + + 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(animeId: String) { + + Singletons + .animeApi + .getAnimeData(animeId) //based on the id + .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) + view.showDetail(anime!!) + + } else { + view.showError("API ERROR : is not successful") + } + } + + override fun onFailure(call: Call, t: Throwable) { + view.showError("API ERROR : onFailure") + } + + }) + } + + 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/controller/DetailTopMangaController.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/DetailTopMangaController.kt new file mode 100644 index 0000000..f9aaa07 --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/DetailTopMangaController.kt @@ -0,0 +1,83 @@ +package xyz.adjutor.aniki.presentation.controller + +import android.content.Context +import android.content.SharedPreferences +import com.google.gson.reflect.TypeToken +import retrofit2.Call +import retrofit2.Callback +import retrofit2.Response +import xyz.adjutor.aniki.presentation.Singletons +import xyz.adjutor.aniki.presentation.Singletons.Companion.gson +import xyz.adjutor.aniki.presentation.model.response.MangaResponse +import xyz.adjutor.aniki.presentation.view.activity.DetailTopMangaActivity +import java.lang.reflect.Type + +class DetailTopMangaController { + + private lateinit var sharedPreferences: SharedPreferences + lateinit var view: DetailTopMangaActivity + + fun onStart(DetailTopMangaActivity: DetailTopMangaActivity, mangaId: String) { + + view = DetailTopMangaActivity + sharedPreferences = + view.applicationContext.getSharedPreferences("sp_manga", Context.MODE_PRIVATE) + + val manga: MangaResponse? = getDataFromCache(mangaId) + if (manga != null) { + view.showDetail(manga) + } else { + //taking the API's fields I want and displaying them + makeApiCall(mangaId) + } + } + + 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(mangaId: String) { + + Singletons + .mangaApi + .getMangaData(mangaId) //based on the id + .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) + view.showDetail(manga!!) + + } else { + view.showError("API ERROR : is not successful") + } + } + + override fun onFailure(call: Call, t: Throwable) { + view.showError("API ERROR : onFailure") + } + + }) + } + + 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/controller/SearchAnimeController.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/SearchAnimeController.kt new file mode 100644 index 0000000..3ee6047 --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/SearchAnimeController.kt @@ -0,0 +1,57 @@ +package xyz.adjutor.aniki.presentation.controller + +import retrofit2.Call +import retrofit2.Callback +import retrofit2.Response +import xyz.adjutor.aniki.presentation.Singletons +import xyz.adjutor.aniki.presentation.model.SearchAnime +import xyz.adjutor.aniki.presentation.model.response.SearchAnimeResponse +import xyz.adjutor.aniki.presentation.view.fragment.SearchAnimeFragment + +class SearchAnimeController { + + lateinit var view: SearchAnimeFragment + + fun onStart(searchAnimeFragment: SearchAnimeFragment) { + + view = searchAnimeFragment + } + + //call the API and show the list + private fun makeApiCall(view: SearchAnimeFragment, query: String) { + + Singletons + .searchAnimeApi + .getSearchAnimeData(q = query) + .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 animeList: List = response.body()!! + .getResults() //getting the "search" field containing our list of SearchAnimes + + view.showList( + view.requireView(), + animeList + ) //calling the method in charge of displaying on the recyclerview + + } else { + view.showError() //a snackbar + } + } + + override fun onFailure(call: Call, t: Throwable) { + view.showError() + } + + }) + } + + fun updateList(userInput: String) { + makeApiCall(view, userInput) + } + +} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/controller/SearchMangaController.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/SearchMangaController.kt new file mode 100644 index 0000000..7d5f92b --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/SearchMangaController.kt @@ -0,0 +1,57 @@ +package xyz.adjutor.aniki.presentation.controller + +import retrofit2.Call +import retrofit2.Callback +import retrofit2.Response +import xyz.adjutor.aniki.presentation.Singletons +import xyz.adjutor.aniki.presentation.model.SearchManga +import xyz.adjutor.aniki.presentation.model.response.SearchMangaResponse +import xyz.adjutor.aniki.presentation.view.fragment.SearchMangaFragment + +class SearchMangaController { + + lateinit var view: SearchMangaFragment + + fun onStart(searchMangaFragment: SearchMangaFragment) { + + view = searchMangaFragment + } + + //call the API and show the list + private fun makeApiCall(view: SearchMangaFragment, query: String) { + + Singletons + .searchMangaApi + .getSearchMangaData(q = query) + .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 mangaList: List = response.body()!! + .getResults() //getting the "search" field containing our list of SearchMangas + + view.showList( + view.requireView(), + mangaList + ) //calling the method in charge of displaying on the recyclerview + + } else { + view.showError() //a snackbar + } + } + + override fun onFailure(call: Call, t: Throwable) { + view.showError() + } + + }) + } + + fun updateList(userInput: String) { + makeApiCall(view, userInput) + } + +} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/controller/TopAnimeController.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/TopAnimeController.kt new file mode 100644 index 0000000..446f4e6 --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/TopAnimeController.kt @@ -0,0 +1,117 @@ +package xyz.adjutor.aniki.presentation.controller + +import android.content.Context +import android.content.SharedPreferences +import android.view.View +import com.google.gson.reflect.TypeToken +import retrofit2.Call +import retrofit2.Callback +import retrofit2.Response +import xyz.adjutor.aniki.presentation.Singletons +import xyz.adjutor.aniki.presentation.Singletons.Companion.gson +import xyz.adjutor.aniki.presentation.model.TopAnime +import xyz.adjutor.aniki.presentation.model.response.TopAnimeResponse +import xyz.adjutor.aniki.presentation.view.fragment.TopAnimeFragment +import java.lang.reflect.Type +import kotlin.properties.Delegates + +class TopAnimeController { + + private lateinit var sharedPreferences: SharedPreferences + private var page by Delegates.notNull() + lateinit var view: TopAnimeFragment + + fun onStart(topAnimeFragment: TopAnimeFragment, viewTopAnimePage: View) { + + view = topAnimeFragment + page = 1 + sharedPreferences = + viewTopAnimePage.context.getSharedPreferences("sp_anime", Context.MODE_PRIVATE) + + + val animeList: List? = getDataFromCache() + if (animeList != null) { + view.showList(viewTopAnimePage, animeList) + } else { + makeApiCall(view, 1) + } + } + + private fun makeApiCall(view: TopAnimeFragment, page: Int) { + + Singletons + .topAnimeApi + .getTopAnimeData(page) + .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 animeList: List = response.body()!! + .getResults() //getting the "top" field containing our list of TopAnimes + saveList(animeList) + view.showList( + view.requireView(), + animeList + ) //calling the method in charge of displaying on the recyclerview + + } else { + view.showError() //a snackbar + } + } + + override fun onFailure(call: Call, t: Throwable) { + view.showError() + } + + }) + } + + private fun saveList(animeList: List) { + val jsonString: String = gson.toJson(animeList) + + sharedPreferences + .edit() + .putString("jsonAnimeList", jsonString) + .apply() + } + + private fun getDataFromCache(): List? { + //the value of the animeList json, if nothing is found, return null + val jsonAnime: String? = sharedPreferences.getString("jsonAnimeList", null) + + //if it's null, well, return null + return if (jsonAnime == null) { + null + } else { //else deserialize the list and return it + val listType: Type = object : TypeToken>() {}.type + gson.fromJson(jsonAnime, listType) + } + } + + + fun onButtonPrevClick() { + if (page > 1) { // if we're not on the first page, because we can't go back if we're on the first one. + page -= 1 + makeApiCall(view, page) + view.showText("Page $page has been loaded.") + } else { + view.showText("You're already on page 1. (If you're actually not, refresh the list.)") + } + } + + fun onButtonNextClick() { + page += 1 + makeApiCall(view, page) + view.showText("Page $page has been loaded.") + } + + fun updateList() { + makeApiCall(view, 1) + view.showText("Data refreshed") + page = 1 + } + +} \ No newline at end of file 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..afdbac7 --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/TopMangaController.kt @@ -0,0 +1,117 @@ +package xyz.adjutor.aniki.presentation.controller + +import android.content.Context +import android.content.SharedPreferences +import android.view.View +import com.google.gson.reflect.TypeToken +import retrofit2.Call +import retrofit2.Callback +import retrofit2.Response +import xyz.adjutor.aniki.presentation.Singletons +import xyz.adjutor.aniki.presentation.Singletons.Companion.gson +import xyz.adjutor.aniki.presentation.model.TopManga +import xyz.adjutor.aniki.presentation.model.response.TopMangaResponse +import xyz.adjutor.aniki.presentation.view.fragment.TopMangaFragment +import java.lang.reflect.Type +import kotlin.properties.Delegates + +class TopMangaController { + + private lateinit var sharedPreferences: SharedPreferences + private var page by Delegates.notNull() + lateinit var view: TopMangaFragment + + fun onStart(topMangaPage: TopMangaFragment, viewTopMangaPage: View) { + + view = topMangaPage + page = 1 + sharedPreferences = + viewTopMangaPage.context.getSharedPreferences("sp_manga", Context.MODE_PRIVATE) + + + val mangaList: List? = getDataFromCache() + if (mangaList != null) { + view.showList(viewTopMangaPage, mangaList) + } else { + makeApiCall(view, 1) + } + } + + private fun makeApiCall(view: TopMangaFragment, page: Int) { + + Singletons + .topMangaApi + .getTopMangaData(page) + .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 mangaList: List = response.body()!! + .getResults() //getting the "top" field containing our list of TopMangas + saveList(mangaList) + view.showList( + view.requireView(), + mangaList + ) //calling the method in charge of displaying on the recyclerview + + } else { + view.showError() //a snackbar + } + } + + override fun onFailure(call: Call, t: Throwable) { + view.showError() + } + + }) + } + + private fun saveList(mangaList: List) { + val jsonString: String = gson.toJson(mangaList) + + sharedPreferences + .edit() + .putString("jsonMangaList", jsonString) + .apply() + } + + private fun getDataFromCache(): List? { + //the value of the mangaList json, if nothing is found, return null + val jsonManga: String? = sharedPreferences.getString("jsonMangaList", null) + + //if it's null, well, return null + return if (jsonManga == null) { + null + } else { //else deserialize the list and return it + val listType: Type = object : TypeToken>() {}.type + gson.fromJson(jsonManga, listType) + } + } + + + fun onButtonPrevClick() { + if (page > 1) { // if we're not on the first page, because we can't go back if we're on the first one. + page -= 1 + makeApiCall(view, page) + view.showText("Page $page has been loaded.") + } else { + view.showText("You're already on page 1. (If you're actually not, refresh the list.)") + } + } + + fun onButtonNextClick() { + page += 1 + makeApiCall(view, page) + view.showText("Page $page has been loaded.") + } + + fun updateList() { + makeApiCall(view, 1) + view.showText("Data refreshed") + page = 1 + } + +} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/controller/anime/DetailSearchAnimeController.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/anime/DetailSearchAnimeController.kt deleted file mode 100644 index e12de3a..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/controller/anime/DetailSearchAnimeController.kt +++ /dev/null @@ -1,56 +0,0 @@ -package xyz.adjutor.aniki.presentation.controller.anime - -import com.google.gson.Gson -import com.google.gson.GsonBuilder -import retrofit2.Call -import retrofit2.Callback -import retrofit2.Response -import xyz.adjutor.aniki.presentation.Singletons -import xyz.adjutor.aniki.presentation.model.anime.AnimeResponse -import xyz.adjutor.aniki.presentation.view.anime.DetailSearchAnimeActivity - -class DetailSearchAnimeController { - - lateinit var gson: Gson - private lateinit var baseUrl: String //the api's base url - lateinit var view: DetailSearchAnimeActivity - - fun onStart(DetailSearchAnimeActivity: DetailSearchAnimeActivity, animeId: String) { - - view = DetailSearchAnimeActivity - baseUrl = "https://api.jikan.moe/" //the api's base url - gson = GsonBuilder() - .setLenient() - .create() - - makeApiCall(baseUrl, animeId) - } - - private fun makeApiCall(BASE_URL: String, animeId: String) { - - Singletons - .animeApi - .getAnimeData(animeId) //based on the id - .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 - view.showDetail(anime!!) - - } else { - view.showError("API ERROR : is not successful") - } - } - - override fun onFailure(call: Call, t: Throwable) { - view.showError("API ERROR : onFailure") - } - - }) - } - -} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/controller/anime/DetailTopAnimeController.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/anime/DetailTopAnimeController.kt deleted file mode 100644 index 3fb13b4..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/controller/anime/DetailTopAnimeController.kt +++ /dev/null @@ -1,90 +0,0 @@ -package xyz.adjutor.aniki.presentation.controller.anime - -import android.content.Context -import android.content.SharedPreferences -import com.google.gson.Gson -import com.google.gson.GsonBuilder -import com.google.gson.reflect.TypeToken -import retrofit2.Call -import retrofit2.Callback -import retrofit2.Response -import xyz.adjutor.aniki.presentation.Singletons -import xyz.adjutor.aniki.presentation.model.anime.AnimeResponse -import xyz.adjutor.aniki.presentation.view.anime.DetailTopAnimeActivity -import java.lang.reflect.Type - -class DetailTopAnimeController { - - private lateinit var sharedPreferences: SharedPreferences - lateinit var gson: Gson - private lateinit var baseUrl: String //the api's base url - lateinit var view: DetailTopAnimeActivity - - fun onStart(DetailTopAnimeActivity: DetailTopAnimeActivity, animeId: String) { - - view = DetailTopAnimeActivity - baseUrl = "https://api.jikan.moe/" //the api's base url - gson = GsonBuilder() - .setLenient() - .create() - sharedPreferences = - view.applicationContext.getSharedPreferences("sp_anime", Context.MODE_PRIVATE) - - val anime: AnimeResponse? = getDataFromCache(animeId) - if (anime != null) { - view.showDetail(anime) - } else { - //taking the API's fields I want and displaying them - makeApiCall(baseUrl, animeId) - } - } - - 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) { - - Singletons - .animeApi - .getAnimeData(animeId) //based on the id - .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) - view.showDetail(anime!!) - - } else { - view.showError("API ERROR : is not successful") - } - } - - override fun onFailure(call: Call, t: Throwable) { - view.showError("API ERROR : onFailure") - } - - }) - } - - 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/controller/anime/SearchAnimeController.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/anime/SearchAnimeController.kt deleted file mode 100644 index 5951f1b..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/controller/anime/SearchAnimeController.kt +++ /dev/null @@ -1,65 +0,0 @@ -package xyz.adjutor.aniki.presentation.controller.anime - -import com.google.gson.Gson -import com.google.gson.GsonBuilder -import retrofit2.Call -import retrofit2.Callback -import retrofit2.Response -import xyz.adjutor.aniki.presentation.Singletons -import xyz.adjutor.aniki.presentation.model.anime.SearchAnime -import xyz.adjutor.aniki.presentation.model.anime.SearchAnimeResponse -import xyz.adjutor.aniki.presentation.view.anime.SearchAnimePage - -class SearchAnimeController { - - lateinit var gson: Gson - lateinit var baseUrl: String //the api's base url - lateinit var view: SearchAnimePage - - fun onStart(searchAnimePage: SearchAnimePage) { - - view = searchAnimePage - baseUrl = "https://api.jikan.moe/" //the api's base url - gson = GsonBuilder() - .setLenient() - .create() - } - - //call the API and show the list - private fun makeApiCall(view: SearchAnimePage, BASE_URL: String, query: String) { - - Singletons - .searchAnimeApi - .getSearchAnimeData(q = query) - .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 animeList: List = response.body()!! - .getResults() //getting the "search" field containing our list of SearchAnimes - - view.showList( - view.requireView(), - animeList - ) //calling the method in charge of displaying on the recyclerview - - } else { - view.showError() //a snackbar - } - } - - override fun onFailure(call: Call, t: Throwable) { - view.showError() - } - - }) - } - - fun updateList(userInput: String) { - makeApiCall(view, baseUrl, userInput) - } - -} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/controller/anime/TopAnimeController.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/anime/TopAnimeController.kt deleted file mode 100644 index 57dc10b..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/controller/anime/TopAnimeController.kt +++ /dev/null @@ -1,124 +0,0 @@ -package xyz.adjutor.aniki.presentation.controller.anime - -import android.content.Context -import android.content.SharedPreferences -import android.view.View -import com.google.gson.Gson -import com.google.gson.GsonBuilder -import com.google.gson.reflect.TypeToken -import retrofit2.Call -import retrofit2.Callback -import retrofit2.Response -import xyz.adjutor.aniki.presentation.Singletons -import xyz.adjutor.aniki.presentation.model.anime.TopAnime -import xyz.adjutor.aniki.presentation.model.anime.TopAnimeResponse -import xyz.adjutor.aniki.presentation.view.anime.TopAnimePage -import java.lang.reflect.Type -import kotlin.properties.Delegates - -class TopAnimeController { - - lateinit var sharedPreferences: SharedPreferences - lateinit var gson: Gson - lateinit var baseUrl: String //the api's base url - var page by Delegates.notNull() - lateinit var view: TopAnimePage - - fun onStart(topAnimePage: TopAnimePage, viewTopAnimePage: View) { - - view = topAnimePage - baseUrl = "https://api.jikan.moe/" //the api's base url - page = 1 - gson = GsonBuilder() - .setLenient() - .create() - sharedPreferences = - viewTopAnimePage.context.getSharedPreferences("sp_anime", Context.MODE_PRIVATE) - - - val animeList: List? = getDataFromCache() - if (animeList != null) { - view.showList(viewTopAnimePage, animeList) - } else { - makeApiCall(view, baseUrl, 1) - } - } - - fun makeApiCall(view: TopAnimePage, BASE_URL: String, page: Int) { - - Singletons - .topAnimeApi - .getTopAnimeData(page) - .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 animeList: List = response.body()!! - .getResults() //getting the "top" field containing our list of TopAnimes - saveList(animeList) - view.showList( - view.requireView(), - animeList - ) //calling the method in charge of displaying on the recyclerview - - } else { - view.showError() //a snackbar - } - } - - override fun onFailure(call: Call, t: Throwable) { - view.showError() - } - - }) - } - - private fun saveList(animeList: List) { - val jsonString: String = gson.toJson(animeList) - - sharedPreferences - .edit() - .putString("jsonAnimeList", jsonString) - .apply() - } - - private fun getDataFromCache(): List? { - //the value of the animeList json, if nothing is found, return null - val jsonAnime: String? = sharedPreferences.getString("jsonAnimeList", null) - - //if it's null, well, return null - return if (jsonAnime == null) { - null - } else { //else deserialize the list and return it - val listType: Type = object : TypeToken>() {}.type - gson.fromJson(jsonAnime, listType) - } - } - - - fun onButtonPrevClick() { - if (page > 1) { // if we're not on the first page, because we can't go back if we're on the first one. - page -= 1 - makeApiCall(view, baseUrl, page) - view.showText("Page $page has been loaded.") - } else { - view.showText("You're already on page 1. (If you're actually not, refresh the list.)") - } - } - - fun onButtonNextClick() { - page += 1 - makeApiCall(view, baseUrl, page) - view.showText("Page $page has been loaded.") - } - - fun updateList() { - makeApiCall(view, baseUrl, 1) - view.showText("Data refreshed") - page = 1 - } - -} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/controller/manga/DetailSearchMangaController.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/manga/DetailSearchMangaController.kt deleted file mode 100644 index 080e4ed..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/controller/manga/DetailSearchMangaController.kt +++ /dev/null @@ -1,56 +0,0 @@ -package xyz.adjutor.aniki.presentation.controller.manga - -import com.google.gson.Gson -import com.google.gson.GsonBuilder -import retrofit2.Call -import retrofit2.Callback -import retrofit2.Response -import xyz.adjutor.aniki.presentation.Singletons -import xyz.adjutor.aniki.presentation.model.manga.MangaResponse -import xyz.adjutor.aniki.presentation.view.manga.DetailSearchMangaActivity - -class DetailSearchMangaController { - - lateinit var gson: Gson - private lateinit var baseUrl: String //the api's base url - lateinit var view: DetailSearchMangaActivity - - fun onStart(DetailSearchMangaActivity: DetailSearchMangaActivity, mangaId: String) { - - view = DetailSearchMangaActivity - baseUrl = "https://api.jikan.moe/" //the api's base url - gson = GsonBuilder() - .setLenient() - .create() - - makeApiCall(baseUrl, mangaId) - } - - private fun makeApiCall(BASE_URL: String, mangaId: String) { - - Singletons - .mangaApi - .getMangaData(mangaId) //based on the id - .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 - view.showDetail(manga!!) - - } else { - view.showError("API ERROR : is not successful") - } - } - - override fun onFailure(call: Call, t: Throwable) { - view.showError("API ERROR : onFailure") - } - - }) - } - -} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/controller/manga/DetailTopMangaController.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/manga/DetailTopMangaController.kt deleted file mode 100644 index 9789d0c..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/controller/manga/DetailTopMangaController.kt +++ /dev/null @@ -1,90 +0,0 @@ -package xyz.adjutor.aniki.presentation.controller.manga - -import android.content.Context -import android.content.SharedPreferences -import com.google.gson.Gson -import com.google.gson.GsonBuilder -import com.google.gson.reflect.TypeToken -import retrofit2.Call -import retrofit2.Callback -import retrofit2.Response -import xyz.adjutor.aniki.presentation.Singletons -import xyz.adjutor.aniki.presentation.model.manga.MangaResponse -import xyz.adjutor.aniki.presentation.view.manga.DetailTopMangaActivity -import java.lang.reflect.Type - -class DetailTopMangaController { - - private lateinit var sharedPreferences: SharedPreferences - lateinit var gson: Gson - private lateinit var baseUrl: String //the api's base url - lateinit var view: DetailTopMangaActivity - - fun onStart(DetailTopMangaActivity: DetailTopMangaActivity, mangaId: String) { - - view = DetailTopMangaActivity - baseUrl = "https://api.jikan.moe/" //the api's base url - gson = GsonBuilder() - .setLenient() - .create() - sharedPreferences = - view.applicationContext.getSharedPreferences("sp_manga", Context.MODE_PRIVATE) - - val manga: MangaResponse? = getDataFromCache(mangaId) - if (manga != null) { - view.showDetail(manga) - } else { - //taking the API's fields I want and displaying them - makeApiCall(baseUrl, mangaId) - } - } - - 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) { - - Singletons - .mangaApi - .getMangaData(mangaId) //based on the id - .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) - view.showDetail(manga!!) - - } else { - view.showError("API ERROR : is not successful") - } - } - - override fun onFailure(call: Call, t: Throwable) { - view.showError("API ERROR : onFailure") - } - - }) - } - - 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/controller/manga/SearchMangaController.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/manga/SearchMangaController.kt deleted file mode 100644 index de1edad..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/controller/manga/SearchMangaController.kt +++ /dev/null @@ -1,65 +0,0 @@ -package xyz.adjutor.aniki.presentation.controller.manga - -import com.google.gson.Gson -import com.google.gson.GsonBuilder -import retrofit2.Call -import retrofit2.Callback -import retrofit2.Response -import xyz.adjutor.aniki.presentation.Singletons -import xyz.adjutor.aniki.presentation.model.manga.SearchManga -import xyz.adjutor.aniki.presentation.model.manga.SearchMangaResponse -import xyz.adjutor.aniki.presentation.view.manga.SearchMangaPage - -class SearchMangaController { - - lateinit var gson: Gson - lateinit var baseUrl: String //the api's base url - lateinit var view: SearchMangaPage - - fun onStart(searchMangaPage: SearchMangaPage) { - - view = searchMangaPage - baseUrl = "https://api.jikan.moe/" //the api's base url - gson = GsonBuilder() - .setLenient() - .create() - } - - //call the API and show the list - private fun makeApiCall(view: SearchMangaPage, BASE_URL: String, query: String) { - - Singletons - .searchMangaApi - .getSearchMangaData(q = query) - .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 mangaList: List = response.body()!! - .getResults() //getting the "search" field containing our list of SearchMangas - - view.showList( - view.requireView(), - mangaList - ) //calling the method in charge of displaying on the recyclerview - - } else { - view.showError() //a snackbar - } - } - - override fun onFailure(call: Call, t: Throwable) { - view.showError() - } - - }) - } - - fun updateList(userInput: String) { - makeApiCall(view, baseUrl, userInput) - } - -} \ No newline at end of file diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/controller/manga/TopMangaController.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/manga/TopMangaController.kt deleted file mode 100644 index ea631fd..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/controller/manga/TopMangaController.kt +++ /dev/null @@ -1,124 +0,0 @@ -package xyz.adjutor.aniki.presentation.controller.manga - -import android.content.Context -import android.content.SharedPreferences -import android.view.View -import com.google.gson.Gson -import com.google.gson.GsonBuilder -import com.google.gson.reflect.TypeToken -import retrofit2.Call -import retrofit2.Callback -import retrofit2.Response -import xyz.adjutor.aniki.presentation.Singletons -import xyz.adjutor.aniki.presentation.model.manga.TopManga -import xyz.adjutor.aniki.presentation.model.manga.TopMangaResponse -import xyz.adjutor.aniki.presentation.view.manga.TopMangaPage -import java.lang.reflect.Type -import kotlin.properties.Delegates - -class TopMangaController { - - lateinit var sharedPreferences: SharedPreferences - lateinit var gson: Gson - lateinit var baseUrl: String //the api's base url - var page by Delegates.notNull() - lateinit var view: TopMangaPage - - fun onStart(topMangaPage: TopMangaPage, viewTopMangaPage: View) { - - view = topMangaPage - baseUrl = "https://api.jikan.moe/" //the api's base url - page = 1 - gson = GsonBuilder() - .setLenient() - .create() - sharedPreferences = - viewTopMangaPage.context.getSharedPreferences("sp_manga", Context.MODE_PRIVATE) - - - val mangaList: List? = getDataFromCache() - if (mangaList != null) { - view.showList(viewTopMangaPage, mangaList) - } else { - makeApiCall(view, baseUrl, 1) - } - } - - private fun makeApiCall(view: TopMangaPage, BASE_URL: String, page: Int) { - - Singletons - .topMangaApi - .getTopMangaData(page) - .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 mangaList: List = response.body()!! - .getResults() //getting the "top" field containing our list of TopMangas - saveList(mangaList) - view.showList( - view.requireView(), - mangaList - ) //calling the method in charge of displaying on the recyclerview - - } else { - view.showError() //a snackbar - } - } - - override fun onFailure(call: Call, t: Throwable) { - view.showError() - } - - }) - } - - private fun saveList(mangaList: List) { - val jsonString: String = gson.toJson(mangaList) - - sharedPreferences - .edit() - .putString("jsonMangaList", jsonString) - .apply() - } - - private fun getDataFromCache(): List? { - //the value of the mangaList json, if nothing is found, return null - val jsonManga: String? = sharedPreferences.getString("jsonMangaList", null) - - //if it's null, well, return null - return if (jsonManga == null) { - null - } else { //else deserialize the list and return it - val listType: Type = object : TypeToken>() {}.type - gson.fromJson(jsonManga, listType) - } - } - - - fun onButtonPrevClick() { - if (page > 1) { // if we're not on the first page, because we can't go back if we're on the first one. - page -= 1 - makeApiCall(view, baseUrl, page) - view.showText("Page $page has been loaded.") - } else { - view.showText("You're already on page 1. (If you're actually not, refresh the list.)") - } - } - - fun onButtonNextClick() { - page += 1 - makeApiCall(view, baseUrl, page) - view.showText("Page $page has been loaded.") - } - - fun updateList() { - makeApiCall(view, baseUrl, 1) - view.showText("Data refreshed") - page = 1 - } - -} \ No newline at end of file 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 new file mode 100644 index 0000000..df5189d --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/model/SearchAnime.kt @@ -0,0 +1,31 @@ +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/SearchManga.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/model/SearchManga.kt new file mode 100644 index 0000000..c24d93c --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/model/SearchManga.kt @@ -0,0 +1,34 @@ +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/TopAnime.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/model/TopAnime.kt new file mode 100644 index 0000000..3cf4390 --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/model/TopAnime.kt @@ -0,0 +1,35 @@ +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/TopManga.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/model/TopManga.kt new file mode 100644 index 0000000..27f63f3 --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/model/TopManga.kt @@ -0,0 +1,36 @@ +package xyz.adjutor.aniki.presentation.model + +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/anime/AnimeResponse.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/model/anime/AnimeResponse.kt deleted file mode 100644 index e4336ce..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/model/anime/AnimeResponse.kt +++ /dev/null @@ -1,16 +0,0 @@ -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 deleted file mode 100644 index 7e4340c..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/model/anime/SearchAnime.kt +++ /dev/null @@ -1,31 +0,0 @@ -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 deleted file mode 100644 index d04aa67..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/model/anime/SearchAnimeResponse.kt +++ /dev/null @@ -1,13 +0,0 @@ -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 deleted file mode 100644 index aefc1c5..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/model/anime/TopAnime.kt +++ /dev/null @@ -1,35 +0,0 @@ -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 deleted file mode 100644 index 48e2f8f..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/model/anime/TopAnimeResponse.kt +++ /dev/null @@ -1,13 +0,0 @@ -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 deleted file mode 100644 index 06aeed0..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/model/manga/MangaResponse.kt +++ /dev/null @@ -1,22 +0,0 @@ -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 deleted file mode 100644 index d69227b..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/model/manga/SearchManga.kt +++ /dev/null @@ -1,34 +0,0 @@ -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 deleted file mode 100644 index 942c071..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/model/manga/SearchMangaResponse.kt +++ /dev/null @@ -1,13 +0,0 @@ -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 deleted file mode 100644 index 4fe3951..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/model/manga/TopManga.kt +++ /dev/null @@ -1,36 +0,0 @@ -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 deleted file mode 100644 index a0f6b8c..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/model/manga/TopMangaResponse.kt +++ /dev/null @@ -1,13 +0,0 @@ -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/model/response/AnimeResponse.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/model/response/AnimeResponse.kt new file mode 100644 index 0000000..c2ef05b --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/model/response/AnimeResponse.kt @@ -0,0 +1,16 @@ +package xyz.adjutor.aniki.presentation.model.response + +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/response/MangaResponse.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/model/response/MangaResponse.kt new file mode 100644 index 0000000..da88a79 --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/model/response/MangaResponse.kt @@ -0,0 +1,22 @@ +package xyz.adjutor.aniki.presentation.model.response + +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/response/SearchAnimeResponse.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/model/response/SearchAnimeResponse.kt new file mode 100644 index 0000000..1400704 --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/model/response/SearchAnimeResponse.kt @@ -0,0 +1,14 @@ +package xyz.adjutor.aniki.presentation.model.response + +import com.google.gson.annotations.SerializedName +import xyz.adjutor.aniki.presentation.model.SearchAnime + +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/response/SearchMangaResponse.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/model/response/SearchMangaResponse.kt new file mode 100644 index 0000000..ed94b95 --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/model/response/SearchMangaResponse.kt @@ -0,0 +1,14 @@ +package xyz.adjutor.aniki.presentation.model.response + +import com.google.gson.annotations.SerializedName +import xyz.adjutor.aniki.presentation.model.SearchManga + +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/response/TopAnimeResponse.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/model/response/TopAnimeResponse.kt new file mode 100644 index 0000000..0c0adb4 --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/model/response/TopAnimeResponse.kt @@ -0,0 +1,14 @@ +package xyz.adjutor.aniki.presentation.model.response + +import com.google.gson.annotations.SerializedName +import xyz.adjutor.aniki.presentation.model.TopAnime + +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/response/TopMangaResponse.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/model/response/TopMangaResponse.kt new file mode 100644 index 0000000..091984c --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/model/response/TopMangaResponse.kt @@ -0,0 +1,14 @@ +package xyz.adjutor.aniki.presentation.model.response + +import com.google.gson.annotations.SerializedName +import xyz.adjutor.aniki.presentation.model.TopManga + +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/HomePage.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/view/HomePage.kt deleted file mode 100644 index f2abca1..0000000 --- a/app/src/main/java/xyz/adjutor/aniki/presentation/view/HomePage.kt +++ /dev/null @@ -1,38 +0,0 @@ -package xyz.adjutor.aniki.presentation.view - -import android.os.Bundle -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.widget.Button -import androidx.fragment.app.Fragment -import androidx.navigation.fragment.findNavController -import xyz.adjutor.aniki.R - -class HomePage : Fragment() { - - override fun onCreateView( - inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? - ): View? { - // Inflate the layout for this fragment - return inflater.inflate(R.layout.home_page, container, false) - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - - view.findViewById