fix EmojiCompat.get().process crash in polls (#2494)
This commit is contained in:
parent
f3d7923803
commit
a2cc622683
|
@ -19,7 +19,6 @@ import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.emoji2.text.EmojiCompat
|
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.keylesspalace.tusky.R
|
import com.keylesspalace.tusky.R
|
||||||
import com.keylesspalace.tusky.databinding.ItemPollBinding
|
import com.keylesspalace.tusky.databinding.ItemPollBinding
|
||||||
|
@ -87,9 +86,8 @@ class PollAdapter : RecyclerView.Adapter<BindingHolder<ItemPollBinding>>() {
|
||||||
when (mode) {
|
when (mode) {
|
||||||
RESULT -> {
|
RESULT -> {
|
||||||
val percent = calculatePercent(option.votesCount, votersCount, voteCount)
|
val percent = calculatePercent(option.votesCount, votersCount, voteCount)
|
||||||
val emojifiedPollOptionText = buildDescription(option.title, percent, option.voted, resultTextView.context)
|
resultTextView.text = buildDescription(option.title, percent, option.voted, resultTextView.context)
|
||||||
.emojify(emojis, resultTextView, animateEmojis)
|
.emojify(emojis, resultTextView, animateEmojis)
|
||||||
resultTextView.text = EmojiCompat.get().process(emojifiedPollOptionText)
|
|
||||||
|
|
||||||
val level = percent * 100
|
val level = percent * 100
|
||||||
val optionColor = if (option.voted) {
|
val optionColor = if (option.voted) {
|
||||||
|
@ -103,8 +101,7 @@ class PollAdapter : RecyclerView.Adapter<BindingHolder<ItemPollBinding>>() {
|
||||||
resultTextView.setOnClickListener(resultClickListener)
|
resultTextView.setOnClickListener(resultClickListener)
|
||||||
}
|
}
|
||||||
SINGLE -> {
|
SINGLE -> {
|
||||||
val emojifiedPollOptionText = option.title.emojify(emojis, radioButton, animateEmojis)
|
radioButton.text = option.title.emojify(emojis, radioButton, animateEmojis)
|
||||||
radioButton.text = EmojiCompat.get().process(emojifiedPollOptionText)
|
|
||||||
radioButton.isChecked = option.selected
|
radioButton.isChecked = option.selected
|
||||||
radioButton.setOnClickListener {
|
radioButton.setOnClickListener {
|
||||||
pollOptions.forEachIndexed { index, pollOption ->
|
pollOptions.forEachIndexed { index, pollOption ->
|
||||||
|
@ -114,8 +111,7 @@ class PollAdapter : RecyclerView.Adapter<BindingHolder<ItemPollBinding>>() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MULTIPLE -> {
|
MULTIPLE -> {
|
||||||
val emojifiedPollOptionText = option.title.emojify(emojis, checkBox, animateEmojis)
|
checkBox.text = option.title.emojify(emojis, checkBox, animateEmojis)
|
||||||
checkBox.text = EmojiCompat.get().process(emojifiedPollOptionText)
|
|
||||||
checkBox.isChecked = option.selected
|
checkBox.isChecked = option.selected
|
||||||
checkBox.setOnCheckedChangeListener { _, isChecked ->
|
checkBox.setOnCheckedChangeListener { _, isChecked ->
|
||||||
pollOptions[holder.bindingAdapterPosition].selected = isChecked
|
pollOptions[holder.bindingAdapterPosition].selected = isChecked
|
||||||
|
|
|
@ -37,7 +37,6 @@ import androidx.core.view.WindowCompat
|
||||||
import androidx.core.view.WindowInsetsCompat
|
import androidx.core.view.WindowInsetsCompat
|
||||||
import androidx.core.view.WindowInsetsCompat.Type.systemBars
|
import androidx.core.view.WindowInsetsCompat.Type.systemBars
|
||||||
import androidx.core.view.updatePadding
|
import androidx.core.view.updatePadding
|
||||||
import androidx.emoji2.text.EmojiCompat
|
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.viewpager2.widget.MarginPageTransformer
|
import androidx.viewpager2.widget.MarginPageTransformer
|
||||||
|
@ -459,14 +458,7 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
|
||||||
*/
|
*/
|
||||||
private fun updateToolbar() {
|
private fun updateToolbar() {
|
||||||
loadedAccount?.let { account ->
|
loadedAccount?.let { account ->
|
||||||
|
supportActionBar?.title = account.name.emojify(account.emojis, binding.accountToolbar, animateEmojis)
|
||||||
val emojifiedName = account.name.emojify(account.emojis, binding.accountToolbar, animateEmojis)
|
|
||||||
|
|
||||||
try {
|
|
||||||
supportActionBar?.title = EmojiCompat.get().process(emojifiedName)
|
|
||||||
} catch (e: IllegalStateException) {
|
|
||||||
supportActionBar?.title = emojifiedName
|
|
||||||
}
|
|
||||||
supportActionBar?.subtitle = String.format(getString(R.string.post_username_format), account.username)
|
supportActionBar?.subtitle = String.format(getString(R.string.post_username_format), account.username)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue