Skip to content

ДЗ по RecyclerView#4

Open
Aluminiy wants to merge 2 commits into
Otus-Android:masterfrom
Aluminiy:master
Open

ДЗ по RecyclerView#4
Aluminiy wants to merge 2 commits into
Otus-Android:masterfrom
Aluminiy:master

Conversation

@Aluminiy
Copy link
Copy Markdown

No description provided.


oldItem is CoinsAdapterItem.Carousel &&
newItem is CoinsAdapterItem.Carousel ->
oldItem.coins.firstOrNull()?.id == newItem.coins.firstOrNull()?.id
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

тут не стоит опираться на первый элемент, он может поменяться, можно сделать вот так:
data class Carousel(val categoryId: String, val coins: List<CoinState>)
и сравнивать по categoryId

import androidx.recyclerview.widget.DefaultItemAnimator
import androidx.recyclerview.widget.RecyclerView

class ItemAnimator : DefaultItemAnimator() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

не реализован animateRemove, который обязателен по условиям задачи

RecyclerView.LayoutParams.WRAP_CONTENT
)
val screenWidth = parent.resources.displayMetrics.widthPixels
params.width = screenWidth / 2 - 16
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

тут 16 это пиксели и они зависят от плотности, лучше переводить все в dp

android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

это задается через менеджер, тут не нужно

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