From e8ecdb88cf646150212f5eaab3997ed4f7a81307 Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Tue, 16 Jul 2019 20:19:57 +0200 Subject: [PATCH] fix avatars and display names in AccountsInListFragment (#1392) * fix avatars and display names in AccountsInListFragment * correctly emojify display names --- .../tusky/AccountsInListFragment.kt | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/AccountsInListFragment.kt b/app/src/main/java/com/keylesspalace/tusky/AccountsInListFragment.kt index 3c6c6cf3..50f04d8b 100644 --- a/app/src/main/java/com/keylesspalace/tusky/AccountsInListFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/AccountsInListFragment.kt @@ -17,6 +17,7 @@ package com.keylesspalace.tusky import android.os.Bundle +import android.preference.PreferenceManager import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -27,13 +28,10 @@ import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView -import com.bumptech.glide.Glide import com.keylesspalace.tusky.di.Injectable import com.keylesspalace.tusky.di.ViewModelFactory import com.keylesspalace.tusky.entity.Account -import com.keylesspalace.tusky.util.Either -import com.keylesspalace.tusky.util.hide -import com.keylesspalace.tusky.util.show +import com.keylesspalace.tusky.util.* import com.keylesspalace.tusky.viewmodel.AccountsInListViewModel import com.keylesspalace.tusky.viewmodel.State import com.uber.autodispose.android.lifecycle.AndroidLifecycleScopeProvider.from @@ -72,6 +70,9 @@ class AccountsInListFragment : DialogFragment(), Injectable { private val adapter = Adapter() 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?) { super.onCreate(savedInstanceState) setStyle(STYLE_NORMAL, R.style.TuskyDialogFragmentStyle) @@ -206,12 +207,9 @@ class AccountsInListFragment : DialogFragment(), Injectable { } fun bind(account: Account) { + displayNameTextView.text = CustomEmojiHelper.emojifyString(account.name, account.emojis, displayNameTextView) usernameTextView.text = account.username - displayNameTextView.text = account.displayName - Glide.with(this@AccountsInListFragment) - .load(account.avatar) - .placeholder(R.drawable.avatar_default) - .into(avatar) + loadAvatar(account.avatar, avatar, radius, animateAvatar) } override fun onClick(v: View?) { @@ -252,12 +250,10 @@ class AccountsInListFragment : DialogFragment(), Injectable { override val containerView = itemView fun bind(account: Account, inAList: Boolean) { + displayNameTextView.text = CustomEmojiHelper.emojifyString(account.name, account.emojis, displayNameTextView) usernameTextView.text = account.username - displayNameTextView.text = account.displayName - Glide.with(this@AccountsInListFragment) - .load(account.avatar) - .placeholder(R.drawable.avatar_default) - .into(avatar) + loadAvatar(account.avatar, avatar, radius, animateAvatar) + rejectButton.apply { if (inAList) { setImageResource(R.drawable.ic_reject_24dp)