feat: toggle fav
This commit is contained in:
parent
c033bb0445
commit
cfb8c3c733
2 changed files with 23 additions and 4 deletions
|
@ -13,6 +13,23 @@ class AnilistMutations {
|
|||
executeQuery<JsonObject>(query, variables)
|
||||
}
|
||||
|
||||
suspend fun toggleFav(type: FavType, id: Int): Boolean {
|
||||
val filter = when (type) {
|
||||
FavType.ANIME -> "animeId"
|
||||
FavType.MANGA -> "mangaId"
|
||||
FavType.CHARACTER -> "characterId"
|
||||
FavType.STAFF -> "staffId"
|
||||
FavType.STUDIO -> "studioId"
|
||||
}
|
||||
val query = """mutation{ToggleFavourite($filter:$id){anime{pageInfo{total}}}}"""
|
||||
val result = executeQuery<JsonObject>(query)
|
||||
return result?.get("errors") == null && result != null
|
||||
}
|
||||
|
||||
enum class FavType {
|
||||
ANIME, MANGA, CHARACTER, STAFF, STUDIO
|
||||
}
|
||||
|
||||
suspend fun editList(
|
||||
mediaID: Int,
|
||||
progress: Int? = null,
|
||||
|
|
|
@ -75,8 +75,8 @@ class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListene
|
|||
finish()
|
||||
return@launch
|
||||
}
|
||||
val following = respond.data.followingPage?.pageInfo?.total?:0
|
||||
val followers = respond.data.followerPage?.pageInfo?.total?:0
|
||||
val following = respond.data.followingPage?.pageInfo?.total ?: 0
|
||||
val followers = respond.data.followerPage?.pageInfo?.total ?: 0
|
||||
withContext(Dispatchers.Main) {
|
||||
binding.profileViewPager.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
bottomMargin = navBarHeight
|
||||
|
@ -270,7 +270,9 @@ class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListene
|
|||
.setDuration(duration).start()
|
||||
ObjectAnimator.ofFloat(binding.profileButtonContainer, "translationX", 0f)
|
||||
.setDuration(duration).start()
|
||||
binding.profileButtonContainer.updateLayoutParams { height = ViewGroup.LayoutParams.WRAP_CONTENT }
|
||||
binding.profileButtonContainer.updateLayoutParams {
|
||||
height = ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
}
|
||||
|
||||
if (PrefManager.getVal(PrefName.BannerAnimations)) binding.profileBannerImage.resume()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue