Merge branch 'fix_crash' into 'master'

Fix crash when clicking on username

Closes #274

See merge request pixeldroid/PixelDroid!299
This commit is contained in:
Matthieu 2021-01-25 16:39:54 +00:00
commit 111182e9b0
1 changed files with 5 additions and 6 deletions

View File

@ -76,7 +76,7 @@ class StatusViewHolder(val binding: PostFragmentBinding) : RecyclerView.ViewHold
binding.username.apply { binding.username.apply {
text = status?.account?.getDisplayName() ?: "" text = status?.account?.getDisplayName() ?: ""
setTypeface(null, Typeface.BOLD) setTypeface(null, Typeface.BOLD)
setOnClickListener { status?.account?.openProfile(rootView.context) } setOnClickListener { status?.account?.openProfile(binding.root.context) }
} }
binding.usernameDesc.apply { binding.usernameDesc.apply {
@ -85,12 +85,12 @@ class StatusViewHolder(val binding: PostFragmentBinding) : RecyclerView.ViewHold
} }
binding.nlikes.apply { binding.nlikes.apply {
text = status?.getNLikes(rootView.context) text = status?.getNLikes(binding.root.context)
setTypeface(null, Typeface.BOLD) setTypeface(null, Typeface.BOLD)
} }
binding.nshares.apply { binding.nshares.apply {
text = status?.getNShares(rootView.context) text = status?.getNShares(binding.root.context)
setTypeface(null, Typeface.BOLD) setTypeface(null, Typeface.BOLD)
} }
@ -176,7 +176,6 @@ class StatusViewHolder(val binding: PostFragmentBinding) : RecyclerView.ViewHold
} }
private fun setDescription( private fun setDescription(
rootView: View,
api: PixelfedAPI, api: PixelfedAPI,
credential: String, credential: String,
lifecycleScope: LifecycleCoroutineScope lifecycleScope: LifecycleCoroutineScope
@ -189,7 +188,7 @@ class StatusViewHolder(val binding: PostFragmentBinding) : RecyclerView.ViewHold
status?.content.orEmpty(), status?.content.orEmpty(),
status?.mentions, status?.mentions,
api, api,
rootView.context, binding.root.context,
credential, credential,
lifecycleScope lifecycleScope
) )
@ -203,7 +202,7 @@ class StatusViewHolder(val binding: PostFragmentBinding) : RecyclerView.ViewHold
val credential = "Bearer ${user.accessToken}" val credential = "Bearer ${user.accessToken}"
//Set the special HTML text //Set the special HTML text
setDescription(binding.root, api, credential, lifecycleScope) setDescription(api, credential, lifecycleScope)
//Activate onclickListeners //Activate onclickListeners
activateLiker( activateLiker(