Open
Conversation
antonkazakov
suggested changes
Aug 15, 2024
|
|
||
| class ChatViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { | ||
|
|
||
| private val mainImg: ShapeableImageView by lazy { itemView.findViewById(R.id.image_icon) } |
Contributor
There was a problem hiding this comment.
здесь нет смысла использовать потокобезопасный lazy, это замедлит работу
| Toast.makeText(this@MainActivity, "Load more", Toast.LENGTH_LONG).show() | ||
| val newChatItems = GenerateChatItems().getList().subList(0, 9).toMutableList() | ||
| items.addAll(newChatItems) | ||
| adapter.notifyDataSetChanged() |
Contributor
There was a problem hiding this comment.
- Перенеси эту логику в адаптер
- Не используй метод notifyDataSetChanged, замени на notifyItemRangeInserted
| val paging = PageScrollListener(manager).apply { | ||
| onLoadMore = { | ||
| Toast.makeText(this@MainActivity, "Load more", Toast.LENGTH_LONG).show() | ||
| val newChatItems = GenerateChatItems().getList().subList(0, 9).toMutableList() |
Contributor
There was a problem hiding this comment.
просто добавляй новый список, без getList и саблиста
| adapter = ChatAdapter(items) | ||
| recyclerView.adapter = adapter | ||
| recyclerView.layoutManager = manager | ||
| recyclerView.setItemViewCacheSize(100) |
Contributor
There was a problem hiding this comment.
А зачем тебе менять размер кеша?
| } | ||
|
|
||
| fun onLoadMore(context: Context) { | ||
| Toast.makeText(context, "Load more", Toast.LENGTH_LONG).show() |
Contributor
There was a problem hiding this comment.
Я бы это логику, и тост и запрос айтемов все таки вынес из адаптера, не его это отвественность
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.