From bd885788c79cfa37bb2ff02faf4ae2516b87b5dd Mon Sep 17 00:00:00 2001 From: Clyhtsuriva Date: Tue, 23 Mar 2021 10:54:41 +0100 Subject: Feature added to animes. Removed the ScrollListener, I prefer to only use buttons for the feature. --- README.md | 4 +-- .../adjutor/aniki/anime/topanime/TopAnimeApi.kt | 5 +-- .../adjutor/aniki/anime/topanime/TopAnimePage.kt | 36 ++++++++++++++++++---- .../adjutor/aniki/manga/topmanga/TopMangaPage.kt | 33 ++++++-------------- app/src/main/res/layout/top_anime_page.xml | 16 ++++++++++ 5 files changed, 60 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 24ea18c..a1f6dcf 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ List of elements used in top manga and top anime with a recycler view SwipeRefresh used to refresh the list of data of the frist page. -Thanks to the scroll listener, touch the bottom of the page to load another page, replacing the first one. -Use the button (prev and next) to navigate with ease through the pages. The "ScrollListener" was added as a practice, it's not the best feature to navigate. +Use the button (prev and next) to navigate with ease through the pages. Details of a chosen element from the recycler view with an intent object Title, synopsys and background clickable. @@ -12,6 +11,7 @@ They display the data in a recycler view similar to the tops. A feature has been added that hides the keyboard when the query is submitted by the user. We can also submit the query by clicking the "search" button that replace the "return" one. Clicking on a searched item also opens a detail page of it. +I'm not adding the "multiple pages" feature to the search section because I assume the user should use a more precise query if what he's looking for doesn't show up in the first page. Multiple calls of the REST API from jikan.moe. Usage of : diff --git a/app/src/main/java/xyz/adjutor/aniki/anime/topanime/TopAnimeApi.kt b/app/src/main/java/xyz/adjutor/aniki/anime/topanime/TopAnimeApi.kt index 8e44e77..2e6b1e0 100644 --- a/app/src/main/java/xyz/adjutor/aniki/anime/topanime/TopAnimeApi.kt +++ b/app/src/main/java/xyz/adjutor/aniki/anime/topanime/TopAnimeApi.kt @@ -2,10 +2,11 @@ package xyz.adjutor.aniki.anime.topanime import retrofit2.Call import retrofit2.http.GET +import retrofit2.http.Path interface TopAnimeApi { - @GET("v3/top/anime") - fun getTopAnimeData(): Call + @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/anime/topanime/TopAnimePage.kt b/app/src/main/java/xyz/adjutor/aniki/anime/topanime/TopAnimePage.kt index d62e5b2..babb7c1 100644 --- a/app/src/main/java/xyz/adjutor/aniki/anime/topanime/TopAnimePage.kt +++ b/app/src/main/java/xyz/adjutor/aniki/anime/topanime/TopAnimePage.kt @@ -31,6 +31,7 @@ class TopAnimePage : Fragment() { .setLenient() .create() var baseUrl = "https://api.jikan.moe/" //the api's base url + var page: Int = 1 override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, @@ -45,10 +46,11 @@ class TopAnimePage : Fragment() { if (animeList != null) { showList(view, animeList) } else { - makeApiCall(view, baseUrl) + makeApiCall(view, baseUrl, 1) } return view + } private fun getDataFromCache(): List? { @@ -71,16 +73,34 @@ class TopAnimePage : Fragment() { view.findViewById