-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Done #1 #35
base: master
Are you sure you want to change the base?
Done #1 #35
Conversation
|
||
class ChatViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { | ||
|
||
private val mainImg: ShapeableImageView by lazy { itemView.findViewById(R.id.image_icon) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
здесь нет смысла использовать потокобезопасный lazy, это замедлит работу
Toast.makeText(this@MainActivity, "Load more", Toast.LENGTH_LONG).show() | ||
val newChatItems = GenerateChatItems().getList().subList(0, 9).toMutableList() | ||
items.addAll(newChatItems) | ||
adapter.notifyDataSetChanged() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Перенеси эту логику в адаптер
- Не используй метод 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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
просто добавляй новый список, без getList и саблиста
adapter = ChatAdapter(items) | ||
recyclerView.adapter = adapter | ||
recyclerView.layoutManager = manager | ||
recyclerView.setItemViewCacheSize(100) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А зачем тебе менять размер кеша?
} | ||
|
||
fun onLoadMore(context: Context) { | ||
Toast.makeText(context, "Load more", Toast.LENGTH_LONG).show() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я бы это логику, и тост и запрос айтемов все таки вынес из адаптера, не его это отвественность
No description provided.