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)
|
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(
|
suspend fun editList(
|
||||||
mediaID: Int,
|
mediaID: Int,
|
||||||
progress: Int? = null,
|
progress: Int? = null,
|
||||||
|
|
|
@ -75,8 +75,8 @@ class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListene
|
||||||
finish()
|
finish()
|
||||||
return@launch
|
return@launch
|
||||||
}
|
}
|
||||||
val following = respond.data.followingPage?.pageInfo?.total?:0
|
val following = respond.data.followingPage?.pageInfo?.total ?: 0
|
||||||
val followers = respond.data.followerPage?.pageInfo?.total?:0
|
val followers = respond.data.followerPage?.pageInfo?.total ?: 0
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
binding.profileViewPager.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
binding.profileViewPager.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||||
bottomMargin = navBarHeight
|
bottomMargin = navBarHeight
|
||||||
|
@ -221,7 +221,7 @@ class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListene
|
||||||
binding.profileMangaCount.text = user.statistics.manga.count.toString()
|
binding.profileMangaCount.text = user.statistics.manga.count.toString()
|
||||||
binding.profileMangaCountContainer.setOnClickListener {
|
binding.profileMangaCountContainer.setOnClickListener {
|
||||||
ContextCompat.startActivity(
|
ContextCompat.startActivity(
|
||||||
this@ProfileActivity, Intent(this@ProfileActivity, ListActivity::class.java)
|
this@ProfileActivity, Intent(this@ProfileActivity, ListActivity::class.java)
|
||||||
.putExtra("anime", false)
|
.putExtra("anime", false)
|
||||||
.putExtra("userId", user.id)
|
.putExtra("userId", user.id)
|
||||||
.putExtra("username", user.name), null
|
.putExtra("username", user.name), null
|
||||||
|
@ -270,7 +270,9 @@ class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListene
|
||||||
.setDuration(duration).start()
|
.setDuration(duration).start()
|
||||||
ObjectAnimator.ofFloat(binding.profileButtonContainer, "translationX", 0f)
|
ObjectAnimator.ofFloat(binding.profileButtonContainer, "translationX", 0f)
|
||||||
.setDuration(duration).start()
|
.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()
|
if (PrefManager.getVal(PrefName.BannerAnimations)) binding.profileBannerImage.resume()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue