diff --git a/app/src/main/java/ani/dantotsu/media/MediaDetailsActivity.kt b/app/src/main/java/ani/dantotsu/media/MediaDetailsActivity.kt index a490721d..d7bb48fa 100644 --- a/app/src/main/java/ani/dantotsu/media/MediaDetailsActivity.kt +++ b/app/src/main/java/ani/dantotsu/media/MediaDetailsActivity.kt @@ -172,7 +172,7 @@ class MediaDetailsActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedLi binding.mediaCoverImage.loadImage(media.cover) binding.mediaCoverImage.setOnLongClickListener { - val coverTitle = "${media.userPreferredName}[Cover]" + val coverTitle = getString(R.string.cover, media.userPreferredName) ImageViewDialog.newInstance( this, coverTitle, @@ -192,7 +192,7 @@ class MediaDetailsActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedLi } override fun onLongClick(event: MotionEvent) { - val bannerTitle = "${media.userPreferredName}[Banner]" + val bannerTitle = getString(R.string.banner, media.userPreferredName) ImageViewDialog.newInstance( this@MediaDetailsActivity, bannerTitle, diff --git a/app/src/main/java/ani/dantotsu/media/MediaInfoFragment.kt b/app/src/main/java/ani/dantotsu/media/MediaInfoFragment.kt index 0302c147..11e532c0 100644 --- a/app/src/main/java/ani/dantotsu/media/MediaInfoFragment.kt +++ b/app/src/main/java/ani/dantotsu/media/MediaInfoFragment.kt @@ -580,7 +580,7 @@ class MediaInfoFragment : Fragment() { ).apply { itemTitle.setText(R.string.social) itemRecycler.adapter = - MediaSocialAdapter(media.users!!, type) + MediaSocialAdapter(media.users!!, type, requireActivity()) itemRecycler.layoutManager = LinearLayoutManager( requireContext(), LinearLayoutManager.HORIZONTAL, diff --git a/app/src/main/java/ani/dantotsu/media/MediaSocialAdapter.kt b/app/src/main/java/ani/dantotsu/media/MediaSocialAdapter.kt index e3233eda..a267cd6b 100644 --- a/app/src/main/java/ani/dantotsu/media/MediaSocialAdapter.kt +++ b/app/src/main/java/ani/dantotsu/media/MediaSocialAdapter.kt @@ -1,28 +1,32 @@ package ani.dantotsu.media -import android.annotation.SuppressLint import android.content.Intent import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.core.content.ContextCompat +import androidx.fragment.app.FragmentActivity import androidx.recyclerview.widget.RecyclerView import ani.dantotsu.R import ani.dantotsu.databinding.ItemFollowerGridBinding import ani.dantotsu.getAppString import ani.dantotsu.loadImage +import ani.dantotsu.others.ImageViewDialog import ani.dantotsu.profile.ProfileActivity import ani.dantotsu.profile.User import ani.dantotsu.setAnimation -class MediaSocialAdapter(private val user: ArrayList, private val type: String) : - RecyclerView.Adapter() { +class MediaSocialAdapter( + val user: ArrayList, + val type: String, + val activity: FragmentActivity +) : RecyclerView.Adapter() { - inner class DeveloperViewHolder(val binding: ItemFollowerGridBinding) : + inner class FollowerGridViewHolder(val binding: ItemFollowerGridBinding) : RecyclerView.ViewHolder(binding.root) - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DeveloperViewHolder { - return DeveloperViewHolder( + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): FollowerGridViewHolder { + return FollowerGridViewHolder( ItemFollowerGridBinding.inflate( LayoutInflater.from(parent.context), parent, @@ -31,8 +35,8 @@ class MediaSocialAdapter(private val user: ArrayList, private val type: St ) } - @SuppressLint("SetTextI18n") - override fun onBindViewHolder(holder: DeveloperViewHolder, position: Int) { + + override fun onBindViewHolder(holder: FollowerGridViewHolder, position: Int) { holder.binding.apply { val user = user[position] val score = user.score?.div(10.0) ?: 0.0 @@ -47,7 +51,7 @@ class MediaSocialAdapter(private val user: ArrayList, private val type: St } profileCompactUserProgress.text = user.progress.toString() profileCompactScore.text = score.toString() - profileCompactTotal.text = " | ${user.totalEpisodes ?: "~"}" + " | ${user.totalEpisodes ?: "~"}".also { profileCompactTotal.text = it } profileUserAvatar.loadImage(user.pfp) val scoreDrawable = if (score == 0.0) R.drawable.score else R.drawable.user_score @@ -59,10 +63,17 @@ class MediaSocialAdapter(private val user: ArrayList, private val type: St profileCompactProgressContainer.visibility = View.VISIBLE profileUserAvatar.setOnClickListener { - val intent = Intent(root.context, ProfileActivity::class.java).apply { - putExtra("userId", user.id) - } - ContextCompat.startActivity(root.context, intent, null) + ContextCompat.startActivity(root.context, + Intent(root.context, ProfileActivity::class.java) + .putExtra("userId", user.id), + null) + } + profileUserAvatarContainer.setOnLongClickListener { + ImageViewDialog.newInstance( + activity, + activity.getString(R.string.avatar, user.name), + user.pfp + ) } } } diff --git a/app/src/main/java/ani/dantotsu/media/comments/CommentItem.kt b/app/src/main/java/ani/dantotsu/media/comments/CommentItem.kt index eea9a6b6..643787fc 100644 --- a/app/src/main/java/ani/dantotsu/media/comments/CommentItem.kt +++ b/app/src/main/java/ani/dantotsu/media/comments/CommentItem.kt @@ -60,211 +60,211 @@ class CommentItem( override fun bind(viewBinding: ItemCommentsBinding, position: Int) { binding = viewBinding setAnimation(binding.root.context, binding.root) - viewBinding.commentRepliesList.layoutManager = - LinearLayoutManager(commentsFragment.activity) - viewBinding.commentRepliesList.adapter = adapter - val isUserComment = CommentsAPI.userId == comment.userId - val levelColor = getAvatarColor(comment.totalVotes, backgroundColor) - markwon.setMarkdown(viewBinding.commentText, comment.content) - viewBinding.commentEdit.visibility = if (isUserComment) View.VISIBLE else View.GONE - if (comment.tag == null) { - viewBinding.commentUserTagLayout.visibility = View.GONE - } else { - viewBinding.commentUserTagLayout.visibility = View.VISIBLE - viewBinding.commentUserTag.text = comment.tag.toString() - } - replying(isReplying) //sets default text - editing(isEditing) - if ((comment.replyCount ?: 0) > 0) { - viewBinding.commentTotalReplies.visibility = View.VISIBLE - viewBinding.commentRepliesDivider.visibility = View.VISIBLE - viewBinding.commentTotalReplies.context.run { - viewBinding.commentTotalReplies.text = if (repliesVisible) - getString(R.string.hide_replies) - else - if (comment.replyCount == 1) - getString(R.string.view_reply) - else - getString(R.string.view_replies_count, comment.replyCount) - } - } else { - viewBinding.commentTotalReplies.visibility = View.GONE - viewBinding.commentRepliesDivider.visibility = View.GONE - } - viewBinding.commentReply.visibility = View.VISIBLE - viewBinding.commentTotalReplies.setOnClickListener { - if (repliesVisible) { - repliesSection.clear() - removeSubCommentIds() - viewBinding.commentTotalReplies.context.run { - viewBinding.commentTotalReplies.text = if (comment.replyCount == 1) - getString(R.string.view_reply) - else - getString(R.string.view_replies_count, comment.replyCount) - } - repliesVisible = false + val item = this + viewBinding.apply { + commentRepliesList.layoutManager = + LinearLayoutManager(commentsFragment.activity) + commentRepliesList.adapter = adapter + val isUserComment = CommentsAPI.userId == comment.userId + val levelColor = getAvatarColor(comment.totalVotes, backgroundColor) + markwon.setMarkdown(commentText, comment.content) + commentEdit.visibility = if (isUserComment) View.VISIBLE else View.GONE + if (comment.tag == null) { + commentUserTagLayout.visibility = View.GONE } else { - viewBinding.commentTotalReplies.setText(R.string.hide_replies) - repliesSection.clear() - commentsFragment.viewReplyCallback(this) - repliesVisible = true + commentUserTagLayout.visibility = View.VISIBLE + commentUserTag.text = comment.tag.toString() + } + replying(isReplying) //sets default text + editing(isEditing) + if ((comment.replyCount ?: 0) > 0) { + commentTotalReplies.visibility = View.VISIBLE + commentRepliesDivider.visibility = View.VISIBLE + commentTotalReplies.context.run { + commentTotalReplies.text = if (repliesVisible) + getString(R.string.hide_replies) + else + if (comment.replyCount == 1) + getString(R.string.view_reply) + else + getString(R.string.view_replies_count, comment.replyCount) + } + } else { + commentTotalReplies.visibility = View.GONE + commentRepliesDivider.visibility = View.GONE + } + commentReply.visibility = View.VISIBLE + commentTotalReplies.setOnClickListener { + if (repliesVisible) { + repliesSection.clear() + removeSubCommentIds() + commentTotalReplies.context.run { + commentTotalReplies.text = if (comment.replyCount == 1) + getString(R.string.view_reply) + else + getString(R.string.view_replies_count, comment.replyCount) + } + repliesVisible = false + } else { + commentTotalReplies.setText(R.string.hide_replies) + repliesSection.clear() + commentsFragment.viewReplyCallback(item) + repliesVisible = true + } } - } - viewBinding.commentUserName.setOnClickListener { - ContextCompat.startActivity( - commentsFragment.activity, - Intent(commentsFragment.activity, ProfileActivity::class.java) - .putExtra("userId", comment.userId.toInt()) - .putExtra("userLVL", "[${levelColor.second}]"), - null - ) - } - viewBinding.commentUserAvatar.setOnClickListener { - ContextCompat.startActivity( - commentsFragment.activity, - Intent(commentsFragment.activity, ProfileActivity::class.java) - .putExtra("userId", comment.userId.toInt()) - .putExtra("userLVL", "[${levelColor.second}]"), - null - ) - } - viewBinding.commentText.setOnLongClickListener { - copyToClipboard(comment.content) - true - } + commentUserName.setOnClickListener { + ContextCompat.startActivity( + commentsFragment.activity, + Intent(commentsFragment.activity, ProfileActivity::class.java) + .putExtra("userId", comment.userId.toInt()), + null + ) + } + commentUserAvatar.setOnClickListener { + ContextCompat.startActivity( + commentsFragment.activity, + Intent(commentsFragment.activity, ProfileActivity::class.java) + .putExtra("userId", comment.userId.toInt()), + null + ) + } + commentText.setOnLongClickListener { + copyToClipboard(comment.content) + true + } - viewBinding.commentEdit.setOnClickListener { - editing(!isEditing) - commentsFragment.editCallback(this) - } - viewBinding.commentReply.setOnClickListener { - replying(!isReplying) - commentsFragment.replyTo(this, comment.username) - commentsFragment.replyCallback(this) - } - viewBinding.modBadge.visibility = if (comment.isMod == true) View.VISIBLE else View.GONE - viewBinding.adminBadge.visibility = if (comment.isAdmin == true) View.VISIBLE else View.GONE - viewBinding.commentInfo.setOnClickListener { - val popup = PopupMenu(commentsFragment.requireContext(), viewBinding.commentInfo) - popup.menuInflater.inflate(R.menu.profile_details_menu, popup.menu) - popup.menu.findItem(R.id.commentDelete)?.isVisible = - isUserComment || CommentsAPI.isAdmin || CommentsAPI.isMod - popup.menu.findItem(R.id.commentBanUser)?.isVisible = - (CommentsAPI.isAdmin || CommentsAPI.isMod) && !isUserComment - popup.menu.findItem(R.id.commentReport)?.isVisible = !isUserComment - popup.setOnMenuItemClickListener { item -> - when (item.itemId) { - R.id.commentReport -> { - dialogBuilder( - getAppString(R.string.report_comment), - getAppString(R.string.report_comment_confirm) - ) { - CoroutineScope(Dispatchers.Main + SupervisorJob()).launch { - val success = CommentsAPI.reportComment( - comment.commentId, - comment.username, - commentsFragment.mediaName, - comment.userId - ) - if (success) { - snackString(R.string.comment_reported) + commentEdit.setOnClickListener { + editing(!isEditing) + commentsFragment.editCallback(item) + } + commentReply.setOnClickListener { + replying(!isReplying) + commentsFragment.replyTo(item, comment.username) + commentsFragment.replyCallback(item) + } + modBadge.visibility = if (comment.isMod == true) View.VISIBLE else View.GONE + adminBadge.visibility = + if (comment.isAdmin == true) View.VISIBLE else View.GONE + commentInfo.setOnClickListener { + val popup = PopupMenu(commentsFragment.requireContext(), commentInfo) + popup.menuInflater.inflate(R.menu.profile_details_menu, popup.menu) + popup.menu.findItem(R.id.commentDelete)?.isVisible = + isUserComment || CommentsAPI.isAdmin || CommentsAPI.isMod + popup.menu.findItem(R.id.commentBanUser)?.isVisible = + (CommentsAPI.isAdmin || CommentsAPI.isMod) && !isUserComment + popup.menu.findItem(R.id.commentReport)?.isVisible = !isUserComment + popup.setOnMenuItemClickListener { item -> + when (item.itemId) { + R.id.commentReport -> { + dialogBuilder( + getAppString(R.string.report_comment), + getAppString(R.string.report_comment_confirm) + ) { + CoroutineScope(Dispatchers.Main + SupervisorJob()).launch { + val success = CommentsAPI.reportComment( + comment.commentId, + comment.username, + commentsFragment.mediaName, + comment.userId + ) + if (success) { + snackString(R.string.comment_reported) + } } } + true } - true - } - R.id.commentDelete -> { - dialogBuilder( - getAppString(R.string.delete_comment), - getAppString(R.string.delete_comment_confirm) - ) { - CoroutineScope(Dispatchers.Main + SupervisorJob()).launch { - val success = CommentsAPI.deleteComment(comment.commentId) - if (success) { - snackString(R.string.comment_deleted) - parentSection.remove(this@CommentItem) + R.id.commentDelete -> { + dialogBuilder( + getAppString(R.string.delete_comment), + getAppString(R.string.delete_comment_confirm) + ) { + CoroutineScope(Dispatchers.Main + SupervisorJob()).launch { + val success = CommentsAPI.deleteComment(comment.commentId) + if (success) { + snackString(R.string.comment_deleted) + parentSection.remove(this@CommentItem) + } } } + true } - true - } - R.id.commentBanUser -> { - dialogBuilder( - getAppString(R.string.ban_user), - getAppString(R.string.ban_user_confirm) - ) { - CoroutineScope(Dispatchers.Main + SupervisorJob()).launch { - val success = CommentsAPI.banUser(comment.userId) - if (success) { - snackString(R.string.user_banned) + R.id.commentBanUser -> { + dialogBuilder( + getAppString(R.string.ban_user), + getAppString(R.string.ban_user_confirm) + ) { + CoroutineScope(Dispatchers.Main + SupervisorJob()).launch { + val success = CommentsAPI.banUser(comment.userId) + if (success) { + snackString(R.string.user_banned) + } } } + true } - true - } - else -> { - false + else -> { + false + } + } + } + popup.show() + } + //fill the icon if the user has liked the comment + setVoteButtons(viewBinding) + commentUpVote.setOnClickListener { + val voteType = if (comment.userVoteType == 1) 0 else 1 + val previousVoteType = comment.userVoteType + val scope = CoroutineScope(Dispatchers.Main + SupervisorJob()) + scope.launch { + val success = CommentsAPI.vote(comment.commentId, voteType) + if (success) { + comment.userVoteType = voteType + + if (previousVoteType == -1) { + comment.downvotes -= 1 + } + comment.upvotes += if (voteType == 1) 1 else -1 + notifyChanged() } } } - popup.show() - } - //fill the icon if the user has liked the comment - setVoteButtons(viewBinding) - viewBinding.commentUpVote.setOnClickListener { - val voteType = if (comment.userVoteType == 1) 0 else 1 - val previousVoteType = comment.userVoteType - val scope = CoroutineScope(Dispatchers.Main + SupervisorJob()) - scope.launch { - val success = CommentsAPI.vote(comment.commentId, voteType) - if (success) { - comment.userVoteType = voteType - if (previousVoteType == -1) { - comment.downvotes -= 1 + commentDownVote.setOnClickListener { + val voteType = if (comment.userVoteType == -1) 0 else -1 + val previousVoteType = comment.userVoteType + val scope = CoroutineScope(Dispatchers.Main + SupervisorJob()) + scope.launch { + val success = CommentsAPI.vote(comment.commentId, voteType) + if (success) { + comment.userVoteType = voteType + if (previousVoteType == 1) { + comment.upvotes -= 1 + } + comment.downvotes += if (voteType == -1) 1 else -1 + notifyChanged() } - comment.upvotes += if (voteType == 1) 1 else -1 - - notifyChanged() } } - } - - viewBinding.commentDownVote.setOnClickListener { - val voteType = if (comment.userVoteType == -1) 0 else -1 - val previousVoteType = comment.userVoteType - val scope = CoroutineScope(Dispatchers.Main + SupervisorJob()) - scope.launch { - val success = CommentsAPI.vote(comment.commentId, voteType) - if (success) { - comment.userVoteType = voteType - - if (previousVoteType == 1) { - comment.upvotes -= 1 - } - comment.downvotes += if (voteType == -1) 1 else -1 - notifyChanged() - } + commentTotalVotes.text = (comment.upvotes - comment.downvotes).toString() + commentUserAvatar.setOnLongClickListener { + ImageViewDialog.newInstance( + commentsFragment.activity, + commentsFragment.activity.getString(R.string.avatar, comment.username), + comment.profilePictureUrl + ) } + comment.profilePictureUrl?.let { commentUserAvatar.loadImage(it) } + commentUserName.text = comment.username + val userColor = "[${levelColor.second}]" + commentUserLevel.text = userColor + commentUserLevel.setTextColor(levelColor.first) + commentUserTime.text = formatTimestamp(comment.timestamp) } - viewBinding.commentTotalVotes.text = (comment.upvotes - comment.downvotes).toString() - viewBinding.commentUserAvatar.setOnLongClickListener { - ImageViewDialog.newInstance( - commentsFragment.activity, - "${comment.username}'s [Cover]", - comment.profilePictureUrl - ) - } - comment.profilePictureUrl?.let { viewBinding.commentUserAvatar.loadImage(it) } - viewBinding.commentUserName.text = comment.username - val userColor = "[${levelColor.second}]" - viewBinding.commentUserLevel.text = userColor - viewBinding.commentUserLevel.setTextColor(levelColor.first) - viewBinding.commentUserTime.text = formatTimestamp(comment.timestamp) } override fun getLayout(): Int { diff --git a/app/src/main/java/ani/dantotsu/profile/ProfileActivity.kt b/app/src/main/java/ani/dantotsu/profile/ProfileActivity.kt index 9e19a5f3..2b0d44c0 100644 --- a/app/src/main/java/ani/dantotsu/profile/ProfileActivity.kt +++ b/app/src/main/java/ani/dantotsu/profile/ProfileActivity.kt @@ -6,6 +6,7 @@ import android.content.res.Configuration import android.os.Bundle import android.view.View import android.view.ViewGroup +import android.widget.ImageView import android.widget.PopupMenu import androidx.appcompat.app.AppCompatActivity import androidx.core.content.ContextCompat @@ -56,6 +57,7 @@ class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListene initActivity(this) binding = ActivityProfileBinding.inflate(layoutInflater) setContentView(binding.root) + val context = this screenWidth = resources.displayMetrics.widthPixels.toFloat() navBar = binding.profileNavBar val navBarRightMargin = if (resources.configuration.orientation == @@ -89,8 +91,7 @@ class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListene finish() return@launch } - val following = respond.data.followingPage?.pageInfo?.total ?: 0 - val followers = respond.data.followerPage?.pageInfo?.total ?: 0 + withContext(Dispatchers.Main) { binding.profileViewPager.updateLayoutParams { bottomMargin = navBarHeight @@ -114,19 +115,23 @@ class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListene }) bindingProfileAppBar = ItemProfileAppBarBinding.bind(binding.root).apply { - - val userLevel = intent.getStringExtra("userLVL") ?: "" + binding.profileProgressBar.visibility = View.GONE followButton.isGone = user.id == Anilist.userid || Anilist.userid == null - followButton.text = getString( - when { - user.isFollowing -> R.string.unfollow - user.isFollower -> R.string.follows_you - else -> R.string.follow - } - ) - if (user.isFollowing && user.isFollower) followButton.text = - getString(R.string.mutual) + + fun followText(): String { + return getString( + when { + user.isFollowing && user.isFollower -> R.string.mutual + user.isFollowing -> R.string.unfollow + user.isFollower -> R.string.follows_you + else -> R.string.follow + } + ) + } + + followButton.text = followText() + followButton.setOnClickListener { lifecycleScope.launch(Dispatchers.IO) { val res = Anilist.query.toggleFollow(user.id) @@ -134,53 +139,21 @@ class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListene withContext(Dispatchers.Main) { snackString(R.string.success) user.isFollowing = res.data.toggleFollow.isFollowing - followButton.text = getString( - when { - user.isFollowing -> R.string.unfollow - user.isFollower -> R.string.follows_you - else -> R.string.follow - } - ) - if (user.isFollowing && user.isFollower) - followButton.text = getString(R.string.mutual) + followButton.text = followText() } } } } - binding.profileProgressBar.visibility = View.GONE profileAppBar.visibility = View.VISIBLE profileMenuButton.setOnClickListener { - val popup = PopupMenu(this@ProfileActivity, profileMenuButton) + val popup = PopupMenu(context, profileMenuButton) popup.menuInflater.inflate(R.menu.menu_profile, popup.menu) popup.setOnMenuItemClickListener { item -> when (item.itemId) { - R.id.action_view_following -> { - ContextCompat.startActivity( - this@ProfileActivity, - Intent(this@ProfileActivity, FollowActivity::class.java) - .putExtra("title", "Following") - .putExtra("userId", user.id), - null - ) - true - } - - R.id.action_view_followers -> { - ContextCompat.startActivity( - this@ProfileActivity, - Intent(this@ProfileActivity, FollowActivity::class.java) - .putExtra("title", "Followers") - .putExtra("userId", user.id), - null - ) - true - } - R.id.action_view_on_anilist -> { openLinkInBrowser("https://anilist.co/user/${user.name}") true } - else -> false } } @@ -190,18 +163,16 @@ class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListene profileUserAvatar.loadImage(user.avatar?.medium) profileUserAvatar.setOnLongClickListener { ImageViewDialog.newInstance( - this@ProfileActivity, - "${user.name}'s [Avatar]", + context, + getString(R.string.avatar, user.name), user.avatar?.medium ) } - - val userLevelText = "${user.name} $userLevel" - profileUserName.text = userLevelText - val bannerAnimations: Boolean = PrefManager.getVal(PrefName.BannerAnimations) + profileUserName.text = user.name + val bannerAnimations: ImageView= if (PrefManager.getVal(PrefName.BannerAnimations)) profileBannerImage else profileBannerImageNoKen blurImage( - if (bannerAnimations) profileBannerImage else profileBannerImageNoKen, + bannerAnimations, user.bannerImage ?: user.avatar?.medium ) profileBannerImage.updateLayoutParams { height += statusBarHeight } @@ -210,34 +181,34 @@ class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListene profileCloseButton.updateLayoutParams { topMargin += statusBarHeight } profileMenuButton.updateLayoutParams { topMargin += statusBarHeight } profileButtonContainer.updateLayoutParams { topMargin += statusBarHeight } + profileBannerImage.setOnLongClickListener { ImageViewDialog.newInstance( - this@ProfileActivity, - user.name + " [Banner]", + context, + getString(R.string.banner, user.name), user.bannerImage ) } mMaxScrollSize = profileAppBar.totalScrollRange - profileAppBar.addOnOffsetChangedListener(this@ProfileActivity) + profileAppBar.addOnOffsetChangedListener(context) - profileFollowerCount.text = followers.toString() + profileFollowerCount.text = (respond.data.followerPage?.pageInfo?.total ?: 0).toString() profileFollowerCountContainer.setOnClickListener { ContextCompat.startActivity( - this@ProfileActivity, - Intent(this@ProfileActivity, FollowActivity::class.java) + context, + Intent(context, FollowActivity::class.java) .putExtra("title", getString(R.string.followers)) .putExtra("userId", user.id), null ) } - - profileFollowingCount.text = following.toString() + profileFollowingCount.text = (respond.data.followingPage?.pageInfo?.total ?: 0).toString() profileFollowingCountContainer.setOnClickListener { ContextCompat.startActivity( - this@ProfileActivity, - Intent(this@ProfileActivity, FollowActivity::class.java) + context, + Intent(context, FollowActivity::class.java) .putExtra("title", "Following") .putExtra("userId", user.id), null @@ -247,8 +218,8 @@ class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListene profileAnimeCount.text = user.statistics.anime.count.toString() profileAnimeCountContainer.setOnClickListener { ContextCompat.startActivity( - this@ProfileActivity, - Intent(this@ProfileActivity, ListActivity::class.java) + context, + Intent(context, ListActivity::class.java) .putExtra("anime", true) .putExtra("userId", user.id) .putExtra("username", user.name), @@ -259,8 +230,8 @@ class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListene profileMangaCount.text = user.statistics.manga.count.toString() profileMangaCountContainer.setOnClickListener { ContextCompat.startActivity( - this@ProfileActivity, - Intent(this@ProfileActivity, ListActivity::class.java) + context, + Intent(context, ListActivity::class.java) .putExtra("anime", false) .putExtra("userId", user.id) .putExtra("username", user.name), diff --git a/app/src/main/res/menu/menu_profile.xml b/app/src/main/res/menu/menu_profile.xml index a39a8010..9cb03021 100644 --- a/app/src/main/res/menu/menu_profile.xml +++ b/app/src/main/res/menu/menu_profile.xml @@ -2,16 +2,6 @@ - - - - Failed to install extension due to conflict READING WATCHING + %1$s\ [Avatar] + %1$s\ [Cover] + %1$s\ [Banner]