Skip to content

Conversation

@AleksVira
Copy link

Доработка RecyclerView:
DiffUtil, payloads, Shared ViewPool, анимация


override fun animateAdd(holder: RecyclerView.ViewHolder): Boolean {
holder.itemView.alpha = 0f
holder.itemView.translationX = -holder.itemView.width.toFloat()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Для установки начального сдвига, но на момент вызова view может быть еще не измерен, и width будет равен 0. Из за этого анимация сдвига не сработает при первом появлении элемента. Лучше использовать measuredWidth или ширину экрана как fallback.

val oldCoin = oldItem.coin
val newCoin = newItem.coin
if (oldCoin.highlight != newCoin.highlight &&
oldCoin.copy(highlight = newCoin.highlight) == newCoin) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Если изменился только highlight, эта проверка всегда будет true, кажется первой достаточно

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants