From 5bd2e3f7d89a2ef624a520064e4711a59755d900 Mon Sep 17 00:00:00 2001 From: Clyhtsuriva Date: Fri, 14 May 2021 08:23:41 +0200 Subject: Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'README.md') diff --git a/README.md b/README.md index da5ecc0..85d9d4d 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ I'm not adding the "multiple pages" feature to the search section because I assu ## API Multiple calls of the REST API from jikan.moe. Usage of : + + /v3/top/manga + /v3/top/anime + /v3/manga @@ -35,6 +36,7 @@ Usage of ScrollView in the detail page. Thus, items with long synopsis and backg ## Design Used my "personal" theme colors for the app. It consists of some colors of the pink/purple "family" : + + very dark purple : #09022A + very light magenta : #FF70FF + strong pink : #D52C70 -- cgit v1.2.3 From 789cb4c6c3e2f4b6bea325b21801d098ebf04623 Mon Sep 17 00:00:00 2001 From: Clyhtsuriva Date: Fri, 14 May 2021 13:26:34 +0200 Subject: Addedd Singletons for TopManga. --- README.md | 6 +++- .../xyz/adjutor/aniki/presentation/Singletons.kt | 23 ++++++++++++++ .../controller/manga/TopMangaController.kt | 37 +++++++++------------- 3 files changed, 43 insertions(+), 23 deletions(-) create mode 100644 app/src/main/java/xyz/adjutor/aniki/presentation/Singletons.kt (limited to 'README.md') diff --git a/README.md b/README.md index 85d9d4d..0762f58 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,11 @@ Also added the "bangers" font for the titles. Development done with a Gitflow workflow. I used master, release, develop and feature branches. ## Architecture -I used the MVC architecture. +I used the MVC (Model, View, Controller) architecture. + +## Singletons +Usage of singletons. +Used to call APIs. ## TO-DO + Finishing MVC diff --git a/app/src/main/java/xyz/adjutor/aniki/presentation/Singletons.kt b/app/src/main/java/xyz/adjutor/aniki/presentation/Singletons.kt new file mode 100644 index 0000000..430f73b --- /dev/null +++ b/app/src/main/java/xyz/adjutor/aniki/presentation/Singletons.kt @@ -0,0 +1,23 @@ +package xyz.adjutor.aniki.presentation + +import com.google.gson.Gson +import com.google.gson.GsonBuilder +import retrofit2.Retrofit +import retrofit2.converter.gson.GsonConverterFactory +import xyz.adjutor.aniki.data.manga.TopMangaApi + +class Singletons { + + companion object { + val gson: Gson = GsonBuilder() + .setLenient() + .create()!! + private const val BASE_URL = "https://api.jikan.moe/" + + val topMangaApi: TopMangaApi = Retrofit.Builder() + .baseUrl(BASE_URL) + .addConverterFactory(GsonConverterFactory.create(gson)) + .build() + .create(TopMangaApi::class.java) + } +} 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 index 845e750..ea631fd 100644 --- 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 @@ -9,9 +9,7 @@ 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.data.manga.TopMangaApi +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 @@ -48,25 +46,20 @@ class TopMangaController { private fun makeApiCall(view: TopMangaPage, BASE_URL: String, page: Int) { - val retrofit = Retrofit.Builder() - .baseUrl(BASE_URL) - .addConverterFactory(GsonConverterFactory.create(gson)) - .build() - - val service = retrofit.create(TopMangaApi::class.java) - val call = service.getTopMangaData(page) - - 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 mangaList: List = response.body()!! - .getResults() //getting the "top" field containing our list of TopMangas - saveList(mangaList) - view.showList( + 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 -- cgit v1.2.3 From e3104c145727c10ff80cad0fe1e916a0a45239eb Mon Sep 17 00:00:00 2001 From: Clyhtsuriva Date: Fri, 14 May 2021 14:25:27 +0200 Subject: Update README.md and adding logo onto the main screen --- README.md | 8 -------- app/src/main/res/layout/home_page.xml | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 10 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 0762f58..9670ac9 100644 --- a/README.md +++ b/README.md @@ -54,11 +54,3 @@ I used the MVC (Model, View, Controller) architecture. ## Singletons Usage of singletons. Used to call APIs. - -## TO-DO -+ Finishing MVC -+ Adding Singleton -+ Clicking on an image opens it full size -+ Firebase -+ Bottom navigation -+ ... diff --git a/app/src/main/res/layout/home_page.xml b/app/src/main/res/layout/home_page.xml index 1c547d6..d9677a9 100644 --- a/app/src/main/res/layout/home_page.xml +++ b/app/src/main/res/layout/home_page.xml @@ -7,6 +7,17 @@ android:background="@color/very_dark_purple" tools:context=".presentation.view.HomePage"> + + + app:layout_constraintBottom_toTopOf="@id/button_top_manga" + app:layout_constraintTop_toTopOf="@id/logo" />