feat(media): fav and popularity count
This commit is contained in:
parent
917ffe644f
commit
d1e03b8237
6 changed files with 167 additions and 109 deletions
|
@ -72,7 +72,7 @@ class AnilistQueries {
|
||||||
media.cameFromContinue = false
|
media.cameFromContinue = false
|
||||||
|
|
||||||
val query =
|
val query =
|
||||||
"""{Media(id:${media.id}){id mediaListEntry{id status score(format:POINT_100)progress private notes repeat customLists updatedAt startedAt{year month day}completedAt{year month day}}isFavourite siteUrl idMal nextAiringEpisode{episode airingAt}source countryOfOrigin format duration season seasonYear startDate{year month day}endDate{year month day}genres studios(isMain:true){nodes{id name siteUrl}}description trailer{site id}synonyms tags{name rank isMediaSpoiler}characters(sort:[ROLE,FAVOURITES_DESC],perPage:25,page:1){edges{role node{id image{medium}name{userPreferred}isFavourite}}}relations{edges{relationType(version:2)node{id idMal mediaListEntry{progress private score(format:POINT_100)status}episodes chapters nextAiringEpisode{episode}popularity meanScore isAdult isFavourite format title{english romaji userPreferred}type status(version:2)bannerImage coverImage{large}}}}staffPreview:staff(perPage:8,sort:[RELEVANCE,ID]){edges{role node{id image{large medium}name{userPreferred}}}}recommendations(sort:RATING_DESC){nodes{mediaRecommendation{id idMal mediaListEntry{progress private score(format:POINT_100)status}episodes chapters nextAiringEpisode{episode}meanScore isAdult isFavourite format title{english romaji userPreferred}type status(version:2)bannerImage coverImage{large}}}}externalLinks{url site}}}"""
|
"""{Media(id:${media.id}){id favourites popularity mediaListEntry{id status score(format:POINT_100)progress private notes repeat customLists updatedAt startedAt{year month day}completedAt{year month day}}isFavourite siteUrl idMal nextAiringEpisode{episode airingAt}source countryOfOrigin format duration season seasonYear startDate{year month day}endDate{year month day}genres studios(isMain:true){nodes{id name siteUrl}}description trailer{site id}synonyms tags{name rank isMediaSpoiler}characters(sort:[ROLE,FAVOURITES_DESC],perPage:25,page:1){edges{role node{id image{medium}name{userPreferred}isFavourite}}}relations{edges{relationType(version:2)node{id idMal mediaListEntry{progress private score(format:POINT_100)status}episodes chapters nextAiringEpisode{episode}popularity meanScore isAdult isFavourite format title{english romaji userPreferred}type status(version:2)bannerImage coverImage{large}}}}staffPreview:staff(perPage:8,sort:[RELEVANCE,ID]){edges{role node{id image{large medium}name{userPreferred}}}}recommendations(sort:RATING_DESC){nodes{mediaRecommendation{id idMal mediaListEntry{progress private score(format:POINT_100)status}episodes chapters nextAiringEpisode{episode}meanScore isAdult isFavourite format title{english romaji userPreferred}type status(version:2)bannerImage coverImage{large}}}}externalLinks{url site}}}"""
|
||||||
runBlocking {
|
runBlocking {
|
||||||
val anilist = async {
|
val anilist = async {
|
||||||
var response = executeQuery<Query.Media>(query, force = true, show = true)
|
var response = executeQuery<Query.Media>(query, force = true, show = true)
|
||||||
|
@ -83,7 +83,8 @@ class AnilistQueries {
|
||||||
media.source = fetchedMedia.source?.toString()
|
media.source = fetchedMedia.source?.toString()
|
||||||
media.countryOfOrigin = fetchedMedia.countryOfOrigin
|
media.countryOfOrigin = fetchedMedia.countryOfOrigin
|
||||||
media.format = fetchedMedia.format?.toString()
|
media.format = fetchedMedia.format?.toString()
|
||||||
|
media.favourites = fetchedMedia.favourites
|
||||||
|
media.popularity = fetchedMedia.popularity
|
||||||
media.startDate = fetchedMedia.startDate
|
media.startDate = fetchedMedia.startDate
|
||||||
media.endDate = fetchedMedia.endDate
|
media.endDate = fetchedMedia.endDate
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ data class Media(
|
||||||
var cover: String? = null,
|
var cover: String? = null,
|
||||||
var banner: String? = null,
|
var banner: String? = null,
|
||||||
var relation: String? = null,
|
var relation: String? = null,
|
||||||
var popularity: Int? = null,
|
var favourites: Int? = null,
|
||||||
|
|
||||||
var isAdult: Boolean,
|
var isAdult: Boolean,
|
||||||
var isFav: Boolean = false,
|
var isFav: Boolean = false,
|
||||||
|
@ -56,6 +56,7 @@ data class Media(
|
||||||
var trailer: String? = null,
|
var trailer: String? = null,
|
||||||
var startDate: FuzzyDate? = null,
|
var startDate: FuzzyDate? = null,
|
||||||
var endDate: FuzzyDate? = null,
|
var endDate: FuzzyDate? = null,
|
||||||
|
var popularity: Int? = null,
|
||||||
|
|
||||||
var characters: ArrayList<Character>? = null,
|
var characters: ArrayList<Character>? = null,
|
||||||
var staff: ArrayList<Author>? = null,
|
var staff: ArrayList<Author>? = null,
|
||||||
|
@ -95,6 +96,7 @@ data class Media(
|
||||||
meanScore = apiMedia.meanScore,
|
meanScore = apiMedia.meanScore,
|
||||||
startDate = apiMedia.startDate,
|
startDate = apiMedia.startDate,
|
||||||
endDate = apiMedia.endDate,
|
endDate = apiMedia.endDate,
|
||||||
|
favourites = apiMedia.favourites,
|
||||||
anime = if (apiMedia.type == MediaType.ANIME) Anime(
|
anime = if (apiMedia.type == MediaType.ANIME) Anime(
|
||||||
totalEpisodes = apiMedia.episodes,
|
totalEpisodes = apiMedia.episodes,
|
||||||
nextAiringEpisode = apiMedia.nextAiringEpisode?.episode?.minus(1)
|
nextAiringEpisode = apiMedia.nextAiringEpisode?.episode?.minus(1)
|
||||||
|
|
|
@ -97,6 +97,8 @@ class MediaInfoFragment : Fragment() {
|
||||||
binding.mediaInfoSource.text = media.source
|
binding.mediaInfoSource.text = media.source
|
||||||
binding.mediaInfoStart.text = media.startDate?.toString() ?: "??"
|
binding.mediaInfoStart.text = media.startDate?.toString() ?: "??"
|
||||||
binding.mediaInfoEnd.text = media.endDate?.toString() ?: "??"
|
binding.mediaInfoEnd.text = media.endDate?.toString() ?: "??"
|
||||||
|
binding.mediaInfoPopularity.text = media.popularity.toString()
|
||||||
|
binding.mediaInfoFavorites.text = media.favourites.toString()
|
||||||
if (media.anime != null) {
|
if (media.anime != null) {
|
||||||
val episodeDuration = media.anime.episodeDuration
|
val episodeDuration = media.anime.episodeDuration
|
||||||
|
|
||||||
|
|
|
@ -129,133 +129,145 @@
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<com.google.android.material.card.MaterialCardView
|
||||||
android:id="@+id/profileButtonContainer"
|
android:id="@+id/profileButtonContainer"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
|
android:layout_marginStart="12dp"
|
||||||
|
android:layout_marginEnd="12dp"
|
||||||
android:layout_marginTop="210dp"
|
android:layout_marginTop="210dp"
|
||||||
android:layout_marginBottom="6dp"
|
android:layout_marginBottom="2dp"
|
||||||
android:layout_marginEnd="8dp"
|
android:backgroundTint="?attr/colorSurfaceVariant"
|
||||||
android:background="?attr/colorSurface"
|
|
||||||
android:baselineAligned="false"
|
android:baselineAligned="false"
|
||||||
android:orientation="horizontal"
|
app:cardCornerRadius="16dp">
|
||||||
tools:ignore="HardcodedText">
|
|
||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
<LinearLayout
|
||||||
android:id="@+id/profileFollowerCountContainer"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:orientation="horizontal"
|
||||||
android:layout_marginStart="8dp"
|
tools:ignore="HardcodedText">
|
||||||
android:backgroundTint="?attr/colorSurfaceVariant"
|
|
||||||
app:cardCornerRadius="16dp">
|
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:id="@+id/profileFollowerCount"
|
android:id="@+id/profileFollowerCountContainer"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_marginTop="8dp"
|
||||||
android:fontFamily="@font/poppins_semi_bold"
|
android:layout_marginBottom="8dp"
|
||||||
android:textColor="?attr/colorPrimary"
|
android:layout_weight="1"
|
||||||
tools:text="1" />
|
android:gravity="center"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:id="@+id/profileFollowerCount"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fontFamily="@font/poppins_semi_bold"
|
||||||
|
android:textColor="?attr/colorPrimary"
|
||||||
|
tools:text="1" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fontFamily="@font/poppins_semi_bold"
|
||||||
|
android:text="Follower" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="3dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?android:attr/listDivider" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/profileFollowingCountContainer"
|
||||||
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_marginTop="24dp"
|
android:layout_marginBottom="8dp"
|
||||||
android:fontFamily="@font/poppins_semi_bold"
|
android:layout_weight="1"
|
||||||
android:text="Follower" />
|
android:gravity="center"
|
||||||
</com.google.android.material.card.MaterialCardView>
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/profileFollowingCount"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fontFamily="@font/poppins_semi_bold"
|
||||||
|
android:textColor="?attr/colorPrimary"
|
||||||
|
tools:text="2" />
|
||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
<TextView
|
||||||
android:id="@+id/profileFollowingCountContainer"
|
android:layout_width="wrap_content"
|
||||||
android:layout_width="0dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:fontFamily="@font/poppins_semi_bold"
|
||||||
android:layout_weight="1"
|
android:text="Following" />
|
||||||
android:layout_marginStart="8dp"
|
|
||||||
android:backgroundTint="?attr/colorSurfaceVariant"
|
|
||||||
app:cardCornerRadius="16dp">
|
|
||||||
|
|
||||||
<TextView
|
</LinearLayout>
|
||||||
android:id="@+id/profileFollowingCount"
|
|
||||||
android:layout_width="wrap_content"
|
<View
|
||||||
|
android:layout_width="3dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?android:attr/listDivider" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/profileAnimeCountContainer"
|
||||||
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_marginTop="8dp"
|
||||||
android:fontFamily="@font/poppins_semi_bold"
|
android:layout_marginBottom="8dp"
|
||||||
android:textColor="?attr/colorPrimary"
|
android:layout_weight="1"
|
||||||
tools:text="2" />
|
android:gravity="center"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:id="@+id/profileAnimeCount"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fontFamily="@font/poppins_semi_bold"
|
||||||
|
android:textColor="?attr/colorPrimary"
|
||||||
|
tools:text="3" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fontFamily="@font/poppins_semi_bold"
|
||||||
|
android:text="Anime" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="3dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?android:attr/listDivider" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/profileMangaCountContainer"
|
||||||
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_marginTop="24dp"
|
android:layout_marginBottom="8dp"
|
||||||
android:fontFamily="@font/poppins_semi_bold"
|
android:layout_weight="1"
|
||||||
android:text="Following" />
|
android:gravity="center"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
<TextView
|
||||||
|
android:id="@+id/profileMangaCount"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fontFamily="@font/poppins_semi_bold"
|
||||||
|
android:textColor="?attr/colorPrimary"
|
||||||
|
tools:text="4" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fontFamily="@font/poppins_semi_bold"
|
||||||
|
android:text="Manga" />
|
||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
</LinearLayout>
|
||||||
android:id="@+id/profileAnimeCountContainer"
|
</LinearLayout>
|
||||||
android:layout_width="0dp"
|
</com.google.android.material.card.MaterialCardView>
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_marginStart="8dp"
|
|
||||||
android:backgroundTint="?attr/colorSurfaceVariant"
|
|
||||||
app:cardCornerRadius="16dp">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/profileAnimeCount"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_horizontal"
|
|
||||||
android:fontFamily="@font/poppins_semi_bold"
|
|
||||||
android:textColor="?attr/colorPrimary"
|
|
||||||
tools:text="3" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_horizontal"
|
|
||||||
android:layout_marginTop="24dp"
|
|
||||||
android:fontFamily="@font/poppins_semi_bold"
|
|
||||||
android:text="Anime" />
|
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
|
||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
|
||||||
android:id="@+id/profileMangaCountContainer"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_marginStart="8dp"
|
|
||||||
android:backgroundTint="?attr/colorSurfaceVariant"
|
|
||||||
app:cardCornerRadius="16dp">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/profileMangaCount"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_horizontal"
|
|
||||||
android:fontFamily="@font/poppins_semi_bold"
|
|
||||||
android:textColor="?attr/colorPrimary"
|
|
||||||
tools:text="4" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_horizontal"
|
|
||||||
android:layout_marginTop="24dp"
|
|
||||||
android:fontFamily="@font/poppins_semi_bold"
|
|
||||||
android:text="Manga" />
|
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -303,7 +303,46 @@
|
||||||
android:fontFamily="@font/poppins_bold"
|
android:fontFamily="@font/poppins_bold"
|
||||||
android:textAlignment="textEnd" />
|
android:textAlignment="textEnd" />
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
<TableRow
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:alpha="0.58"
|
||||||
|
android:text="@string/popularity"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/mediaInfoPopularity"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:fontFamily="@font/poppins_bold"
|
||||||
|
android:textAlignment="textEnd" />
|
||||||
|
</TableRow>
|
||||||
|
<TableRow
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:alpha="0.58"
|
||||||
|
android:text="@string/favourites"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/mediaInfoFavorites"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:fontFamily="@font/poppins_bold"
|
||||||
|
android:textAlignment="textEnd" />
|
||||||
|
</TableRow>
|
||||||
<View
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="16dp" />
|
android:layout_height="16dp" />
|
||||||
|
|
|
@ -124,6 +124,8 @@
|
||||||
<string name="characters">Characters</string>
|
<string name="characters">Characters</string>
|
||||||
<string name="relations">Relations</string>
|
<string name="relations">Relations</string>
|
||||||
<string name="staff">Staff</string>
|
<string name="staff">Staff</string>
|
||||||
|
<string name="favourites">Favourites</string>
|
||||||
|
<string name="popularity">Popularity</string>
|
||||||
|
|
||||||
<string name="roles">Roles</string>
|
<string name="roles">Roles</string>
|
||||||
<string name="details">Details</string>
|
<string name="details">Details</string>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue