From a815bac15d314068fac7282a3aefd029d846d04f Mon Sep 17 00:00:00 2001 From: aayush262 Date: Mon, 1 Apr 2024 19:31:32 +0530 Subject: [PATCH] feat: 18+ media on infinite scroll too --- .../connections/anilist/AnilistQueries.kt | 2 ++ .../connections/anilist/AnilistViewModel.kt | 20 ++++++++++++------- .../profile/{activity => }/UsersAdapter.kt | 7 +++---- .../dantotsu/profile/UsersDialogFragment.kt | 2 -- 4 files changed, 18 insertions(+), 13 deletions(-) rename app/src/main/java/ani/dantotsu/profile/{activity => }/UsersAdapter.kt (89%) diff --git a/app/src/main/java/ani/dantotsu/connections/anilist/AnilistQueries.kt b/app/src/main/java/ani/dantotsu/connections/anilist/AnilistQueries.kt index 8e83a9e5..625f8c5f 100644 --- a/app/src/main/java/ani/dantotsu/connections/anilist/AnilistQueries.kt +++ b/app/src/main/java/ani/dantotsu/connections/anilist/AnilistQueries.kt @@ -894,6 +894,7 @@ class AnilistQueries { season: String? = null, id: Int? = null, hd: Boolean = false, + adultOnly: Boolean = false ): SearchResults? { val query = """ query (${"$"}page: Int = 1, ${"$"}id: Int, ${"$"}type: MediaType, ${"$"}isAdult: Boolean = false, ${"$"}search: String, ${"$"}format: [MediaFormat], ${"$"}status: MediaStatus, ${"$"}countryOfOrigin: CountryCode, ${"$"}source: MediaSource, ${"$"}season: MediaSeason, ${"$"}seasonYear: Int, ${"$"}year: String, ${"$"}onList: Boolean, ${"$"}yearLesser: FuzzyDateInt, ${"$"}yearGreater: FuzzyDateInt, ${"$"}episodeLesser: Int, ${"$"}episodeGreater: Int, ${"$"}durationLesser: Int, ${"$"}durationGreater: Int, ${"$"}chapterLesser: Int, ${"$"}chapterGreater: Int, ${"$"}volumeLesser: Int, ${"$"}volumeGreater: Int, ${"$"}licensedBy: [String], ${"$"}isLicensed: Boolean, ${"$"}genres: [String], ${"$"}excludedGenres: [String], ${"$"}tags: [String], ${"$"}excludedTags: [String], ${"$"}minimumTagRank: Int, ${"$"}sort: [MediaSort] = [POPULARITY_DESC, SCORE_DESC]) { @@ -941,6 +942,7 @@ query (${"$"}page: Int = 1, ${"$"}id: Int, ${"$"}type: MediaType, ${"$"}isAdult: } """.replace("\n", " ").replace(""" """, "") val variables = """{"type":"$type","isAdult":$isAdult + ${if (adultOnly) ""","isAdult":true""" else ""} ${if (onList != null) ""","onList":$onList""" else ""} ${if (page != null) ""","page":"$page"""" else ""} ${if (id != null) ""","id":"$id"""" else ""} diff --git a/app/src/main/java/ani/dantotsu/connections/anilist/AnilistViewModel.kt b/app/src/main/java/ani/dantotsu/connections/anilist/AnilistViewModel.kt index 243e2792..e96e1376 100644 --- a/app/src/main/java/ani/dantotsu/connections/anilist/AnilistViewModel.kt +++ b/app/src/main/java/ani/dantotsu/connections/anilist/AnilistViewModel.kt @@ -137,7 +137,8 @@ class AnilistAnimeViewModel : ViewModel() { sort = Anilist.sortBy[2], season = season, seasonYear = year, - hd = true + hd = true, + adultOnly = PrefManager.getVal(PrefName.AdultOnly) )?.results ) } @@ -159,7 +160,8 @@ class AnilistAnimeViewModel : ViewModel() { search = searchVal, onList = if (onList) null else false, sort = sort, - genres = genres + genres = genres, + adultOnly = PrefManager.getVal(PrefName.AdultOnly) ) ) } @@ -176,7 +178,8 @@ class AnilistAnimeViewModel : ViewModel() { r.tags, r.format, r.isAdult, - r.onList + r.onList, + adultOnly = PrefManager.getVal(PrefName.AdultOnly), ) ) @@ -241,7 +244,8 @@ class AnilistMangaViewModel : ViewModel() { type, perPage = 10, sort = Anilist.sortBy[2], - hd = true + hd = true, + adultOnly = PrefManager.getVal(PrefName.AdultOnly) )?.results ) @@ -261,7 +265,8 @@ class AnilistMangaViewModel : ViewModel() { search = searchVal, onList = if (onList) null else false, sort = sort, - genres = genres + genres = genres, + adultOnly = PrefManager.getVal(PrefName.AdultOnly) ) ) } @@ -282,7 +287,8 @@ class AnilistMangaViewModel : ViewModel() { r.excludedGenres, r.excludedTags, r.seasonYear, - r.season + r.season, + adultOnly = PrefManager.getVal(PrefName.AdultOnly) ) ) @@ -342,7 +348,7 @@ class AnilistSearch : ViewModel() { r.excludedGenres, r.excludedTags, r.seasonYear, - r.season + r.season, ) ) diff --git a/app/src/main/java/ani/dantotsu/profile/activity/UsersAdapter.kt b/app/src/main/java/ani/dantotsu/profile/UsersAdapter.kt similarity index 89% rename from app/src/main/java/ani/dantotsu/profile/activity/UsersAdapter.kt rename to app/src/main/java/ani/dantotsu/profile/UsersAdapter.kt index 52763e09..9f31d27b 100644 --- a/app/src/main/java/ani/dantotsu/profile/activity/UsersAdapter.kt +++ b/app/src/main/java/ani/dantotsu/profile/UsersAdapter.kt @@ -1,14 +1,13 @@ -package ani.dantotsu.profile.activity +package ani.dantotsu.profile import android.content.Intent import android.view.LayoutInflater import android.view.ViewGroup import androidx.core.content.ContextCompat import androidx.recyclerview.widget.RecyclerView +import ani.dantotsu.blurImage import ani.dantotsu.databinding.ItemFollowerBinding import ani.dantotsu.loadImage -import ani.dantotsu.profile.ProfileActivity -import ani.dantotsu.profile.User import ani.dantotsu.setAnimation @@ -41,7 +40,7 @@ class UsersAdapter(private val user: ArrayList) : RecyclerView.Adapter