aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/xyz/adjutor/aniki/presentation/controller
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/xyz/adjutor/aniki/presentation/controller')
-rw-r--r--app/src/main/java/xyz/adjutor/aniki/presentation/controller/DetailSearchAnimeController.kt (renamed from app/src/main/java/xyz/adjutor/aniki/presentation/controller/anime/DetailSearchAnimeController.kt)18
-rw-r--r--app/src/main/java/xyz/adjutor/aniki/presentation/controller/DetailSearchMangaController.kt (renamed from app/src/main/java/xyz/adjutor/aniki/presentation/controller/manga/DetailSearchMangaController.kt)18
-rw-r--r--app/src/main/java/xyz/adjutor/aniki/presentation/controller/DetailTopAnimeController.kt (renamed from app/src/main/java/xyz/adjutor/aniki/presentation/controller/anime/DetailTopAnimeController.kt)19
-rw-r--r--app/src/main/java/xyz/adjutor/aniki/presentation/controller/DetailTopMangaController.kt (renamed from app/src/main/java/xyz/adjutor/aniki/presentation/controller/manga/DetailTopMangaController.kt)19
-rw-r--r--app/src/main/java/xyz/adjutor/aniki/presentation/controller/SearchAnimeController.kt (renamed from app/src/main/java/xyz/adjutor/aniki/presentation/controller/anime/SearchAnimeController.kt)26
-rw-r--r--app/src/main/java/xyz/adjutor/aniki/presentation/controller/SearchMangaController.kt (renamed from app/src/main/java/xyz/adjutor/aniki/presentation/controller/manga/SearchMangaController.kt)26
-rw-r--r--app/src/main/java/xyz/adjutor/aniki/presentation/controller/TopAnimeController.kt (renamed from app/src/main/java/xyz/adjutor/aniki/presentation/controller/anime/TopAnimeController.kt)37
-rw-r--r--app/src/main/java/xyz/adjutor/aniki/presentation/controller/TopMangaController.kt (renamed from app/src/main/java/xyz/adjutor/aniki/presentation/controller/manga/TopMangaController.kt)35
8 files changed, 69 insertions, 129 deletions
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/DetailSearchAnimeController.kt
index e12de3a..95aabec 100644
--- a/app/src/main/java/xyz/adjutor/aniki/presentation/controller/anime/DetailSearchAnimeController.kt
+++ b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/DetailSearchAnimeController.kt
@@ -1,32 +1,24 @@
-package xyz.adjutor.aniki.presentation.controller.anime
+package xyz.adjutor.aniki.presentation.controller
-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
+import xyz.adjutor.aniki.presentation.model.response.AnimeResponse
+import xyz.adjutor.aniki.presentation.view.activity.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)
+ makeApiCall(animeId)
}
- private fun makeApiCall(BASE_URL: String, animeId: String) {
+ private fun makeApiCall(animeId: String) {
Singletons
.animeApi
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/DetailSearchMangaController.kt
index 080e4ed..d2f718a 100644
--- a/app/src/main/java/xyz/adjutor/aniki/presentation/controller/manga/DetailSearchMangaController.kt
+++ b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/DetailSearchMangaController.kt
@@ -1,32 +1,24 @@
-package xyz.adjutor.aniki.presentation.controller.manga
+package xyz.adjutor.aniki.presentation.controller
-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
+import xyz.adjutor.aniki.presentation.model.response.MangaResponse
+import xyz.adjutor.aniki.presentation.view.activity.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)
+ makeApiCall(mangaId)
}
- private fun makeApiCall(BASE_URL: String, mangaId: String) {
+ private fun makeApiCall(mangaId: String) {
Singletons
.mangaApi
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/DetailTopAnimeController.kt
index 3fb13b4..46e7edd 100644
--- a/app/src/main/java/xyz/adjutor/aniki/presentation/controller/anime/DetailTopAnimeController.kt
+++ b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/DetailTopAnimeController.kt
@@ -1,32 +1,25 @@
-package xyz.adjutor.aniki.presentation.controller.anime
+package xyz.adjutor.aniki.presentation.controller
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 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 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)
@@ -35,7 +28,7 @@ class DetailTopAnimeController {
view.showDetail(anime)
} else {
//taking the API's fields I want and displaying them
- makeApiCall(baseUrl, animeId)
+ makeApiCall(animeId)
}
}
@@ -50,7 +43,7 @@ class DetailTopAnimeController {
}
}
- private fun makeApiCall(BASE_URL: String, animeId: String) {
+ private fun makeApiCall(animeId: String) {
Singletons
.animeApi
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/DetailTopMangaController.kt
index 9789d0c..f9aaa07 100644
--- a/app/src/main/java/xyz/adjutor/aniki/presentation/controller/manga/DetailTopMangaController.kt
+++ b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/DetailTopMangaController.kt
@@ -1,32 +1,25 @@
-package xyz.adjutor.aniki.presentation.controller.manga
+package xyz.adjutor.aniki.presentation.controller
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 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 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)
@@ -35,7 +28,7 @@ class DetailTopMangaController {
view.showDetail(manga)
} else {
//taking the API's fields I want and displaying them
- makeApiCall(baseUrl, mangaId)
+ makeApiCall(mangaId)
}
}
@@ -50,7 +43,7 @@ class DetailTopMangaController {
}
}
- private fun makeApiCall(BASE_URL: String, mangaId: String) {
+ private fun makeApiCall(mangaId: String) {
Singletons
.mangaApi
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/SearchAnimeController.kt
index 5951f1b..3ee6047 100644
--- a/app/src/main/java/xyz/adjutor/aniki/presentation/controller/anime/SearchAnimeController.kt
+++ b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/SearchAnimeController.kt
@@ -1,32 +1,24 @@
-package xyz.adjutor.aniki.presentation.controller.anime
+package xyz.adjutor.aniki.presentation.controller
-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
+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 gson: Gson
- lateinit var baseUrl: String //the api's base url
- lateinit var view: SearchAnimePage
+ lateinit var view: SearchAnimeFragment
- fun onStart(searchAnimePage: SearchAnimePage) {
+ fun onStart(searchAnimeFragment: SearchAnimeFragment) {
- view = searchAnimePage
- baseUrl = "https://api.jikan.moe/" //the api's base url
- gson = GsonBuilder()
- .setLenient()
- .create()
+ view = searchAnimeFragment
}
//call the API and show the list
- private fun makeApiCall(view: SearchAnimePage, BASE_URL: String, query: String) {
+ private fun makeApiCall(view: SearchAnimeFragment, query: String) {
Singletons
.searchAnimeApi
@@ -59,7 +51,7 @@ class SearchAnimeController {
}
fun updateList(userInput: String) {
- makeApiCall(view, baseUrl, userInput)
+ makeApiCall(view, userInput)
}
} \ 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/SearchMangaController.kt
index de1edad..7d5f92b 100644
--- a/app/src/main/java/xyz/adjutor/aniki/presentation/controller/manga/SearchMangaController.kt
+++ b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/SearchMangaController.kt
@@ -1,32 +1,24 @@
-package xyz.adjutor.aniki.presentation.controller.manga
+package xyz.adjutor.aniki.presentation.controller
-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
+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 gson: Gson
- lateinit var baseUrl: String //the api's base url
- lateinit var view: SearchMangaPage
+ lateinit var view: SearchMangaFragment
- fun onStart(searchMangaPage: SearchMangaPage) {
+ fun onStart(searchMangaFragment: SearchMangaFragment) {
- view = searchMangaPage
- baseUrl = "https://api.jikan.moe/" //the api's base url
- gson = GsonBuilder()
- .setLenient()
- .create()
+ view = searchMangaFragment
}
//call the API and show the list
- private fun makeApiCall(view: SearchMangaPage, BASE_URL: String, query: String) {
+ private fun makeApiCall(view: SearchMangaFragment, query: String) {
Singletons
.searchMangaApi
@@ -59,7 +51,7 @@ class SearchMangaController {
}
fun updateList(userInput: String) {
- makeApiCall(view, baseUrl, userInput)
+ makeApiCall(view, 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/TopAnimeController.kt
index 57dc10b..446f4e6 100644
--- a/app/src/main/java/xyz/adjutor/aniki/presentation/controller/anime/TopAnimeController.kt
+++ b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/TopAnimeController.kt
@@ -1,37 +1,30 @@
-package xyz.adjutor.aniki.presentation.controller.anime
+package xyz.adjutor.aniki.presentation.controller
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 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 {
- lateinit var sharedPreferences: SharedPreferences
- lateinit var gson: Gson
- lateinit var baseUrl: String //the api's base url
- var page by Delegates.notNull<Int>()
- lateinit var view: TopAnimePage
+ private lateinit var sharedPreferences: SharedPreferences
+ private var page by Delegates.notNull<Int>()
+ lateinit var view: TopAnimeFragment
- fun onStart(topAnimePage: TopAnimePage, viewTopAnimePage: View) {
+ fun onStart(topAnimeFragment: TopAnimeFragment, viewTopAnimePage: View) {
- view = topAnimePage
- baseUrl = "https://api.jikan.moe/" //the api's base url
+ view = topAnimeFragment
page = 1
- gson = GsonBuilder()
- .setLenient()
- .create()
sharedPreferences =
viewTopAnimePage.context.getSharedPreferences("sp_anime", Context.MODE_PRIVATE)
@@ -40,11 +33,11 @@ class TopAnimeController {
if (animeList != null) {
view.showList(viewTopAnimePage, animeList)
} else {
- makeApiCall(view, baseUrl, 1)
+ makeApiCall(view, 1)
}
}
- fun makeApiCall(view: TopAnimePage, BASE_URL: String, page: Int) {
+ private fun makeApiCall(view: TopAnimeFragment, page: Int) {
Singletons
.topAnimeApi
@@ -102,7 +95,7 @@ class TopAnimeController {
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)
+ 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.)")
@@ -111,12 +104,12 @@ class TopAnimeController {
fun onButtonNextClick() {
page += 1
- makeApiCall(view, baseUrl, page)
+ makeApiCall(view, page)
view.showText("Page $page has been loaded.")
}
fun updateList() {
- makeApiCall(view, baseUrl, 1)
+ makeApiCall(view, 1)
view.showText("Data refreshed")
page = 1
}
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/TopMangaController.kt
index ea631fd..afdbac7 100644
--- a/app/src/main/java/xyz/adjutor/aniki/presentation/controller/manga/TopMangaController.kt
+++ b/app/src/main/java/xyz/adjutor/aniki/presentation/controller/TopMangaController.kt
@@ -1,37 +1,30 @@
-package xyz.adjutor.aniki.presentation.controller.manga
+package xyz.adjutor.aniki.presentation.controller
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 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 {
- lateinit var sharedPreferences: SharedPreferences
- lateinit var gson: Gson
- lateinit var baseUrl: String //the api's base url
- var page by Delegates.notNull<Int>()
- lateinit var view: TopMangaPage
+ private lateinit var sharedPreferences: SharedPreferences
+ private var page by Delegates.notNull<Int>()
+ lateinit var view: TopMangaFragment
- fun onStart(topMangaPage: TopMangaPage, viewTopMangaPage: View) {
+ fun onStart(topMangaPage: TopMangaFragment, 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)
@@ -40,11 +33,11 @@ class TopMangaController {
if (mangaList != null) {
view.showList(viewTopMangaPage, mangaList)
} else {
- makeApiCall(view, baseUrl, 1)
+ makeApiCall(view, 1)
}
}
- private fun makeApiCall(view: TopMangaPage, BASE_URL: String, page: Int) {
+ private fun makeApiCall(view: TopMangaFragment, page: Int) {
Singletons
.topMangaApi
@@ -102,7 +95,7 @@ class TopMangaController {
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)
+ 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.)")
@@ -111,12 +104,12 @@ class TopMangaController {
fun onButtonNextClick() {
page += 1
- makeApiCall(view, baseUrl, page)
+ makeApiCall(view, page)
view.showText("Page $page has been loaded.")
}
fun updateList() {
- makeApiCall(view, baseUrl, 1)
+ makeApiCall(view, 1)
view.showText("Data refreshed")
page = 1
}