Skip to content

Homework_10 implementation(RecyclerView)#58

Open
Vp-Ma wants to merge 1 commit intoAndroid-Developer-Basic:masterfrom
Vp-Ma:master
Open

Homework_10 implementation(RecyclerView)#58
Vp-Ma wants to merge 1 commit intoAndroid-Developer-Basic:masterfrom
Vp-Ma:master

Conversation

@Vp-Ma
Copy link

@Vp-Ma Vp-Ma commented Jan 5, 2026

No description provided.

private var ChatItemList = mutableListOf<ChatTlgItem>()
fun setList(list: List<ChatTlgItem>) {
ChatItemList = list.toList() as MutableList<ChatTlgItem>
notifyDataSetChanged()

Choose a reason for hiding this comment

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

При каждом обновлении списка перерисовываются все элементы через notifyDataSetChanged. Если будем использовать ListAdapter с DiffUtil.ItemCallback, то обновит только измененные элементы и улучшит производительность.

direction: Int
) {
val itemPosition:Int = viewHolder.adapterPosition
adapter.onItemSwipe( itemPosition, direction )

Choose a reason for hiding this comment

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

Если добавить проверку позиции перед использованием, будет безопаснее при быстрых свайпах

if (!recyclerView.canScrollVertically(1)) {
var chatAddList = ChatTlgService( false )
ChatTlgList = ChatTlgList + chatAddList.getTlgChat()
chatTlgAdapter.setList( ChatTlgList )

Choose a reason for hiding this comment

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

При достижении конца списка onScrolled может вызываться несколько раз подряд. Флаг isLoading для защиты от повторных вызовов будет хорошо смотреться

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