feat: toggle fav

This commit is contained in:
rebelonion 2024-03-17 01:00:08 -05:00
parent c033bb0445
commit cfb8c3c733
2 changed files with 23 additions and 4 deletions

View file

@ -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,

View file

@ -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
@ -221,7 +221,7 @@ class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListene
binding.profileMangaCount.text = user.statistics.manga.count.toString()
binding.profileMangaCountContainer.setOnClickListener {
ContextCompat.startActivity(
this@ProfileActivity, Intent(this@ProfileActivity, ListActivity::class.java)
this@ProfileActivity, Intent(this@ProfileActivity, ListActivity::class.java)
.putExtra("anime", false)
.putExtra("userId", user.id)
.putExtra("username", user.name), null
@ -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()
}