Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

dmilkov97
Copy link

No description provided.


class ChatViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {

private val mainImg: ShapeableImageView by lazy { itemView.findViewById(R.id.image_icon) }
Copy link
Contributor

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()
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Перенеси эту логику в адаптер
  2. Не используй метод 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()
Copy link
Contributor

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)
Copy link
Contributor

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()
Copy link
Contributor

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