fix avatars and display names in AccountsInListFragment (#1392)

* fix avatars and display names in AccountsInListFragment

* correctly emojify display names
This commit is contained in:
Konrad Pozniak 2019-07-16 20:19:57 +02:00 committed by GitHub
parent b1c2fcc157
commit e8ecdb88cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -17,6 +17,7 @@
package com.keylesspalace.tusky package com.keylesspalace.tusky
import android.os.Bundle import android.os.Bundle
import android.preference.PreferenceManager
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -27,13 +28,10 @@ import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.keylesspalace.tusky.di.Injectable import com.keylesspalace.tusky.di.Injectable
import com.keylesspalace.tusky.di.ViewModelFactory import com.keylesspalace.tusky.di.ViewModelFactory
import com.keylesspalace.tusky.entity.Account import com.keylesspalace.tusky.entity.Account
import com.keylesspalace.tusky.util.Either import com.keylesspalace.tusky.util.*
import com.keylesspalace.tusky.util.hide
import com.keylesspalace.tusky.util.show
import com.keylesspalace.tusky.viewmodel.AccountsInListViewModel import com.keylesspalace.tusky.viewmodel.AccountsInListViewModel
import com.keylesspalace.tusky.viewmodel.State import com.keylesspalace.tusky.viewmodel.State
import com.uber.autodispose.android.lifecycle.AndroidLifecycleScopeProvider.from import com.uber.autodispose.android.lifecycle.AndroidLifecycleScopeProvider.from
@ -72,6 +70,9 @@ class AccountsInListFragment : DialogFragment(), Injectable {
private val adapter = Adapter() private val adapter = Adapter()
private val searchAdapter = SearchAdapter() private val searchAdapter = SearchAdapter()
private val radius by lazy { resources.getDimensionPixelSize(R.dimen.avatar_radius_48dp) }
private val animateAvatar by lazy { PreferenceManager.getDefaultSharedPreferences(requireContext()).getBoolean("animateGifAvatars", false) }
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setStyle(STYLE_NORMAL, R.style.TuskyDialogFragmentStyle) setStyle(STYLE_NORMAL, R.style.TuskyDialogFragmentStyle)
@ -206,12 +207,9 @@ class AccountsInListFragment : DialogFragment(), Injectable {
} }
fun bind(account: Account) { fun bind(account: Account) {
displayNameTextView.text = CustomEmojiHelper.emojifyString(account.name, account.emojis, displayNameTextView)
usernameTextView.text = account.username usernameTextView.text = account.username
displayNameTextView.text = account.displayName loadAvatar(account.avatar, avatar, radius, animateAvatar)
Glide.with(this@AccountsInListFragment)
.load(account.avatar)
.placeholder(R.drawable.avatar_default)
.into(avatar)
} }
override fun onClick(v: View?) { override fun onClick(v: View?) {
@ -252,12 +250,10 @@ class AccountsInListFragment : DialogFragment(), Injectable {
override val containerView = itemView override val containerView = itemView
fun bind(account: Account, inAList: Boolean) { fun bind(account: Account, inAList: Boolean) {
displayNameTextView.text = CustomEmojiHelper.emojifyString(account.name, account.emojis, displayNameTextView)
usernameTextView.text = account.username usernameTextView.text = account.username
displayNameTextView.text = account.displayName loadAvatar(account.avatar, avatar, radius, animateAvatar)
Glide.with(this@AccountsInListFragment)
.load(account.avatar)
.placeholder(R.drawable.avatar_default)
.into(avatar)
rejectButton.apply { rejectButton.apply {
if (inAList) { if (inAList) {
setImageResource(R.drawable.ic_reject_24dp) setImageResource(R.drawable.ic_reject_24dp)