feat: user profile data
This commit is contained in:
parent
a401ab89f3
commit
da22347267
4 changed files with 110 additions and 12 deletions
|
@ -11,7 +11,6 @@ import android.os.Bundle
|
|||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.provider.Settings
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.animation.AnticipateInterpolator
|
||||
|
@ -54,7 +53,6 @@ import eu.kanade.domain.source.service.SourcePreferences
|
|||
import io.noties.markwon.Markwon
|
||||
import io.noties.markwon.SoftBreakAddsNewLinePlugin
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
@ -95,7 +93,6 @@ class MainActivity : AppCompatActivity() {
|
|||
}
|
||||
_bottomBar.background = ContextCompat.getDrawable(this, R.drawable.bottom_nav_gray)
|
||||
|
||||
|
||||
val offset = try {
|
||||
val statusBarHeightId = resources.getIdentifier("status_bar_height", "dimen", "android")
|
||||
resources.getDimensionPixelSize(statusBarHeightId)
|
||||
|
|
|
@ -52,6 +52,13 @@ class AnilistQueries {
|
|||
return true
|
||||
}
|
||||
|
||||
suspend fun getUserProfile(id: Int): Query.UserProfileResponse? {
|
||||
return executeQuery<Query.UserProfileResponse>(
|
||||
"""{user:User(id:$id){id,name,about(asHtml:true)avatar{medium,large},bannerImage,isFollowing,isFollower,isBlocked,favourites{anime{nodes{coverImage{extraLarge,large,medium,color}}}manga{nodes{coverImage{extraLarge,large,medium,color}}}characters{nodes{image{large,medium}}}staff{nodes{image{large,medium}}}studios{nodes{name}}}statistics{anime{count,meanScore,standardDeviation,minutesWatched,episodesWatched,chaptersRead,volumesRead}manga{count,meanScore,standardDeviation,minutesWatched,episodesWatched,chaptersRead,volumesRead}}siteUrl}}""",
|
||||
force = true
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun getMedia(id: Int, mal: Boolean = false): Media? {
|
||||
val response = executeQuery<Query.Media>(
|
||||
"""{Media(${if (!mal) "id:" else "idMal:"}$id){id idMal status chapters episodes nextAiringEpisode{episode}type meanScore isAdult isFavourite format bannerImage coverImage{large}title{english romaji userPreferred}mediaListEntry{progress private score(format:POINT_100)status}}}""",
|
||||
|
|
|
@ -174,6 +174,100 @@ class Query {
|
|||
val user: ani.dantotsu.connections.anilist.api.User?
|
||||
)
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class UserProfileResponse(
|
||||
@SerialName("data")
|
||||
val data: Data
|
||||
) {
|
||||
@Serializable
|
||||
data class Data(
|
||||
@SerialName("user")
|
||||
val user: UserProfile?
|
||||
)
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class UserProfile(
|
||||
@SerialName("id")
|
||||
val id: Int,
|
||||
@SerialName("name")
|
||||
val name: String,
|
||||
@SerialName("about")
|
||||
val about: String?,
|
||||
@SerialName("avatar")
|
||||
val avatar: UserAvatar?,
|
||||
@SerialName("bannerImage")
|
||||
val bannerImage: String?,
|
||||
@SerialName("isFollowing")
|
||||
val isFollowing: Boolean,
|
||||
@SerialName("isFollower")
|
||||
val isFollower: Boolean,
|
||||
@SerialName("isBlocked")
|
||||
val isBlocked: Boolean,
|
||||
@SerialName("favorites")
|
||||
val favorites: UserFavorites?,
|
||||
@SerialName("statistics")
|
||||
val statistics: UserStatisticTypes,
|
||||
@SerialName("siteUrl")
|
||||
val siteUrl: String,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class UserFavorites(
|
||||
@SerialName("anime")
|
||||
val anime: UserMediaFavoritesCollection,
|
||||
@SerialName("manga")
|
||||
val manga: UserMediaFavoritesCollection,
|
||||
@SerialName("characters")
|
||||
val characters: UserCharacterFavoritesCollection,
|
||||
@SerialName("staff")
|
||||
val staff: UserStaffFavoritesCollection,
|
||||
@SerialName("studios")
|
||||
val studios: UserStudioFavoritesCollection,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class UserMediaFavoritesCollection(
|
||||
@SerialName("nodes")
|
||||
val nodes: List<UserMediaImageFavorite>,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class UserMediaImageFavorite(
|
||||
@SerialName("coverImage")
|
||||
val coverImage: MediaCoverImage
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class UserCharacterFavoritesCollection(
|
||||
@SerialName("nodes")
|
||||
val nodes: List<UserCharacterImageFavorite>,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class UserCharacterImageFavorite(
|
||||
@SerialName("image")
|
||||
val image: CharacterImage
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class UserStaffFavoritesCollection(
|
||||
@SerialName("nodes")
|
||||
val nodes: List<UserCharacterImageFavorite>, //downstream it's the same as character
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class UserStudioFavoritesCollection(
|
||||
@SerialName("nodes")
|
||||
val nodes: List<UserStudioFavorite>,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class UserStudioFavorite(
|
||||
@SerialName("name")
|
||||
val name: String,
|
||||
)
|
||||
}
|
||||
|
||||
//data class WhaData(
|
||||
|
|
|
@ -115,20 +115,20 @@ data class UserAvatar(
|
|||
|
||||
@Serializable
|
||||
data class UserStatisticTypes(
|
||||
@SerialName("anime") var anime: UserStatistics?,
|
||||
@SerialName("manga") var manga: UserStatistics?
|
||||
@SerialName("anime") var anime: UserStatistics,
|
||||
@SerialName("manga") var manga: UserStatistics
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class UserStatistics(
|
||||
//
|
||||
@SerialName("count") var count: Int?,
|
||||
@SerialName("meanScore") var meanScore: Float?,
|
||||
@SerialName("standardDeviation") var standardDeviation: Float?,
|
||||
@SerialName("minutesWatched") var minutesWatched: Int?,
|
||||
@SerialName("episodesWatched") var episodesWatched: Int?,
|
||||
@SerialName("chaptersRead") var chaptersRead: Int?,
|
||||
@SerialName("volumesRead") var volumesRead: Int?,
|
||||
@SerialName("count") var count: Int,
|
||||
@SerialName("meanScore") var meanScore: Float,
|
||||
@SerialName("standardDeviation") var standardDeviation: Float,
|
||||
@SerialName("minutesWatched") var minutesWatched: Int,
|
||||
@SerialName("episodesWatched") var episodesWatched: Int,
|
||||
@SerialName("chaptersRead") var chaptersRead: Int,
|
||||
@SerialName("volumesRead") var volumesRead: Int,
|
||||
// @SerialName("formats") var formats: List<UserFormatStatistic>?,
|
||||
// @SerialName("statuses") var statuses: List<UserStatusStatistic>?,
|
||||
// @SerialName("scores") var scores: List<UserScoreStatistic>?,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue