feat: open user links in dantotsu
This commit is contained in:
parent
353452dd21
commit
5c2ae57d77
6 changed files with 67 additions and 16 deletions
|
@ -1347,6 +1347,18 @@ Page(page:$page,perPage:50) {
|
|||
)
|
||||
}
|
||||
|
||||
suspend fun getUserProfile(username: String): Query.UserProfileResponse? {
|
||||
val id = getUserId(username) ?: return null
|
||||
return getUserProfile(id)
|
||||
}
|
||||
|
||||
suspend fun getUserId(username: String): Int? {
|
||||
return executeQuery<Query.User>(
|
||||
"""{User(name:"$username"){id}}""",
|
||||
force = true
|
||||
)?.data?.user?.id
|
||||
}
|
||||
|
||||
suspend fun getUserStatistics(id: Int, sort: String = "ID"): Query.StatisticsResponse? {
|
||||
return executeQuery<Query.StatisticsResponse>(
|
||||
"""{User(id:$id){id name mediaListOptions{scoreFormat}statistics{anime{...UserStatistics}manga{...UserStatistics}}}}fragment UserStatistics on UserStatistics{count meanScore standardDeviation minutesWatched episodesWatched chaptersRead volumesRead formats(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds format}statuses(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds status}scores(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds score}lengths(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds length}releaseYears(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds releaseYear}startYears(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds startYear}genres(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds genre}tags(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds tag{id name}}countries(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds country}voiceActors(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds voiceActor{id name{first middle last full native alternative userPreferred}}characterIds}staff(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds staff{id name{first middle last full native alternative userPreferred}}}studios(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds studio{id name isAnimationStudio}}}""",
|
||||
|
|
|
@ -11,20 +11,27 @@ import ani.dantotsu.themes.ThemeManager
|
|||
class UrlMedia : Activity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
ThemeManager(this).applyTheme()
|
||||
var id: Int? = intent?.extras?.getInt("media", 0) ?: 0
|
||||
var isMAL = false
|
||||
var continueMedia = true
|
||||
if (id == 0) {
|
||||
continueMedia = false
|
||||
val data: Uri? = intent?.data
|
||||
isMAL = data?.host != "anilist.co"
|
||||
id = data?.pathSegments?.getOrNull(1)?.toIntOrNull()
|
||||
} else loadMedia = id
|
||||
startMainActivity(
|
||||
this,
|
||||
bundleOf("mediaId" to id, "mal" to isMAL, "continue" to continueMedia)
|
||||
)
|
||||
val data: Uri? = intent?.data
|
||||
val type = data?.pathSegments?.getOrNull(0)
|
||||
if (type == "anime" || type == "manga") {
|
||||
var id: Int? = intent?.extras?.getInt("media", 0) ?: 0
|
||||
var isMAL = false
|
||||
var continueMedia = true
|
||||
if (id == 0) {
|
||||
continueMedia = false
|
||||
isMAL = data.host != "anilist.co"
|
||||
id = data.pathSegments?.getOrNull(1)?.toIntOrNull()
|
||||
} else loadMedia = id
|
||||
startMainActivity(
|
||||
this,
|
||||
bundleOf("mediaId" to id, "mal" to isMAL, "continue" to continueMedia)
|
||||
)
|
||||
} else if (type == "user") {
|
||||
val username = data.pathSegments?.getOrNull(1)
|
||||
startMainActivity(this, bundleOf("username" to username))
|
||||
} else {
|
||||
startMainActivity(this)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue