{"id":421307,"date":"2024-06-30T04:01:13","date_gmt":"2024-06-30T04:01:13","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=421307"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=421307","title":{"rendered":"<span>MultiItem \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u0434\u043b\u044f RecyclerView \u0432 40 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430 \u0441 BRVAH<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u042d\u0442\u043e \u0442\u0440\u0435\u0442\u044c\u044f \u0447\u0430\u0441\u0442\u044c \u0446\u0438\u043a\u043b\u0430 \u0441\u0442\u0430\u0442\u0435\u0439 \u043f\u0440\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u043e\u0432 \u0434\u043b\u044f RecyclerView c BRVAH.<\/p>\n<p>\u041f\u0440\u043e\u0448\u043b\u044b\u0435 \u0447\u0430\u0441\u0442\u0438:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/576342\/\" rel=\"noopener noreferrer nofollow\">\u0427\u0430\u0441\u0442\u044c 1. \u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/576946\/\" rel=\"noopener noreferrer nofollow\">\u0427\u0430\u0441\u0442\u044c 2. \u041f\u0430\u0433\u0438\u043d\u0430\u0446\u0438\u044f \u0438 diffUtils \u0432 RecyclerView \u0441 BRVAH<\/a><\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u044e:<\/p>\n<ul>\n<li>\n<p>\u0410\u043d\u0438\u043c\u0430\u0446\u0438\u044e \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 layout \u0432 \u043e\u0434\u043d\u043e\u043c \u0441\u043f\u0438\u0441\u043a\u0435<\/p>\n<\/li>\n<\/ul>\n<p>\u041e\u0434\u0438\u043d \u0438\u0437 \u0447\u0430\u0441\u0442\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0431\u0438\u0437\u043d\u0435\u0441\u0430 \u0432 \u0446\u0435\u043b\u043e\u043c \u0438 \u0434\u0438\u0437\u0430\u0439\u043d\u0430 \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u2013 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435. \u0412 \u044d\u0442\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u043f\u044f\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0439<\/p>\n<ul>\n<li>\n<p>AlphaInAnimation() \u2013 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438\u0437 \u043d\u0435\u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438    <\/p>\n<\/li>\n<li>\n<p>ScaleInAnimation() \u2013 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441 \u0435\u0433\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435\u043c<\/p>\n<\/li>\n<li>\n<p>SlideInBottomAnimation() \u2013 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441\u043d\u0438\u0437\u0443    <\/p>\n<\/li>\n<li>\n<p>SlideInLeftAnimation() \u2013 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441\u043b\u0435\u0432\u0430    <\/p>\n<\/li>\n<li>\n<p>SlideInRightAnimation() \u2013 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441\u043f\u0440\u0430\u0432\u0430<\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0432\u0448\u0438\u0441\u044c \u043e\u0442 <strong>BaseAnimation<\/strong><\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 \u043a\u043e\u0434\u0430<\/p>\n<pre><code class=\"kotlin\">adapter.adapterAnimation = SlideInRightAnimation()<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d9d\/07d\/658\/d9d07d658fa8e4265b3d389402a69eb7.gif\" width=\"640\" height=\"1184\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d9d\/07d\/658\/d9d07d658fa8e4265b3d389402a69eb7.gif\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u044e \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044c \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0440\u0430\u0437\u043d\u044b\u0445 layout \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430, \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f:    <\/p>\n<ul>\n<li>\n<p>\u0421\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u043f\u043e\u0434\u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430\u043c\u0438    <\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u00ab\u043f\u0440\u0435\u043c\u0438\u0443\u043c\u00bb \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f, \u043d\u0430 \u0434\u043e\u0441\u043a\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0439    <\/p>\n<\/li>\n<\/ul>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u044e \u043f\u0435\u0440\u0432\u0443\u044e \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044c. Layout, \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0442\u043e\u043b\u044c\u043a\u043e TextView, \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ad9\/a7b\/733\/ad9a7b7333c32b3c614cb31b4e26aae7.png\" width=\"591\" height=\"192\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ad9\/a7b\/733\/ad9a7b7333c32b3c614cb31b4e26aae7.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0421\u043e\u0437\u0434\u0430\u043b \u043d\u043e\u0432\u044b\u0439 \u0430\u0434\u0430\u043f\u0442\u0435\u0440. \u0414\u043b\u044f \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430, \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 <strong>BaseSectionQuickAdapter<\/strong>. \u041f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 \u0435\u0433\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0435\u0449\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c layout \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430. \u0415\u0449\u0435 \u0437\u043d\u0430\u0447\u0438\u043c\u043e\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u0435, \u043f\u0440\u0438 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430, DataClass \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <strong>SectionEntity<\/strong>, \u043f\u0440\u043e \u043d\u0435\u0433\u043e \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043f\u043e\u0437\u0436\u0435. \u041f\u0440\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0435\u0449\u0435 \u043c\u0435\u0442\u043e\u0434 <strong>convertHeader. <\/strong>\u0412 \u043d\u0435\u043c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 layout \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430.<\/p>\n<pre><code class=\"kotlin\">class SectionAdapter(data: MutableList&lt;NotificationWithSectionsDTO>) : BaseSectionQuickAdapter&lt;NotificationWithSectionsDTO, BaseViewHolder>(R.layout.item_section_header, R.layout.item_notification_with_image, data) {      init {         addChildClickViewIds(R.id.ivState)     }      override fun convert(holder: BaseViewHolder, item: NotificationWithSectionsDTO) {         holder.setGone(R.id.view, holder.layoutPosition == 0)             .setText(R.id.tvDateTime, item.date)             .setText(R.id.tvDsc, item.text)             .setImageResource(                 R.id.ivState,                 if (item.isRead) R.drawable.ic_delete                 else R.drawable.ic_read             )          val imageView = holder.getView&lt;ImageView>(R.id.imageView)         val context = holder.itemView.context          Glide.with(context)             .load(item.imageUrl)             .circleCrop()             .into(imageView)     }      override fun convertHeader(helper: BaseViewHolder, item: NotificationWithSectionsDTO) {         helper.setText(R.id.tvHeader, item.titleText)     } } <\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0443 \u043a DataClass\u0443. \u041e\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <strong>SectionEntity. <\/strong>\u0412 \u043d\u0435\u043c \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <strong>isHeader<\/strong> &#8212; \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u043c. \u041e\u043f\u0438\u0448\u0443 \u043d\u043e\u0432\u044b\u0439 DataClass    <\/p>\n<pre><code class=\"kotlin\">data class NotificationWithSectionsDTO(     val date: String = \"\",     val text: String = \"\",     var isRead: Boolean = false,     val imageUrl: String = \"\",     val titleText: String = \"\", ) : SectionEntity {     override val isHeader: Boolean         get() = titleText.isNotBlank() } <\/code><\/pre>\n<p>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430 \u043d\u0435 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 \u043f\u0440\u043e\u0448\u043b\u044b\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445<\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/18a\/eb4\/80e\/18aeb480e7367fcff36f749c6d5f696f.gif\" width=\"640\" height=\"1184\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/18a\/eb4\/80e\/18aeb480e7367fcff36f749c6d5f696f.gif\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0421\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u2013 \u044d\u0442\u043e \u0447\u0430\u0441\u0442\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438, \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0435 \u0434\u0432\u0443\u043c\u044f layout. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u044e \u0431\u043e\u043b\u0435\u0435 \u043e\u0431\u0448\u0438\u0440\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. <\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e, \u0441\u0434\u0435\u043b\u0430\u044e \u043f\u043e\u0434\u043e\u0431\u0438\u0435 \u0434\u043e\u0441\u043a\u0438 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0439, \u0441 \u043e\u0431\u044b\u0447\u043d\u044b\u043c\u0438 \u0438 \u00ab\u043f\u0440\u0435\u043c\u0438\u0443\u043c\u00bb \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438.<\/p>\n<p>\u041d\u0430\u0447\u043d\u0443 \u0441 DataClass. \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0443\u043b\u044c\u0442\u0438\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u0438 \u043a\u043b\u0430\u0441\u0441 \u0434\u0430\u043d\u043d\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <strong>MultiItemEntity.<\/strong> \u0412 \u043d\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u043c\u0435\u0442\u043e\u0434 <strong>itemType<\/strong>: Int, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 \u0442\u0438\u043f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430.<\/p>\n<pre><code class=\"kotlin\">data class MessageDTO(     val text: String,     val price: String,     val image: String,     val mayAgreement: Boolean = false,     val type: Int = typeNotPremium ) : MultiItemEntity {     companion object {         const val typePremium = 0         const val typeNotPremium = 1     }      override val itemType: Int         get() = this.type } <\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u043b \u0434\u0432\u0430 \u0442\u0438\u043f\u0430 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0439 \u00ab\u043f\u0440\u0435\u043c\u0438\u0443\u043c\u00bb \u0438 \u00ab\u043d\u0435 \u043f\u0440\u0435\u043c\u0438\u0443\u043c\u00bb, <strong>itemType<\/strong> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u0445.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u043b \u0430\u0434\u0430\u043f\u0442\u0435\u0440. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 <strong>BaseMultiItemQuickAdapter<\/strong>. \u0415\u043c\u0443 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f layout\u044b, \u043e\u043d\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u043c <strong>addItemType. <\/strong>\u041c\u0435\u0442\u043e\u0434 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b itemType: Int \u0438 layoutId: Int. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e <strong>BaseQuickAdapter<\/strong>, \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u043d\u0430 \u0442\u0438\u043f\u044b. \u0414\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430, \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 convret, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u043c\u0435\u0442\u043e\u0434 \u0445\u043e\u043b\u0434\u0435\u0440\u0430 <strong>holder.itemViewType. <\/strong>\u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u0438\u043f\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u2013 \u043f\u0440\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<pre><code class=\"kotlin\">class MultiItemAdapter(data: MutableList&lt;MessageDTO>?) : BaseMultiItemQuickAdapter&lt;MessageDTO, BaseViewHolder>(data) {     init {         addItemType(MessageDTO.typeNotPremium, R.layout.item_message)         addItemType(MessageDTO.typePremium, R.layout.item_mesage_premium)     }      override fun convert(holder: BaseViewHolder, item: MessageDTO) {         val imageView = holder.getView&lt;ImageView>(R.id.ivMsg)         val context = holder.itemView.context          Glide.with(context)             .load(item.image)             .into(imageView)          when (holder.itemViewType) {             MessageDTO.typePremium -> {                 holder.setText(R.id.tvNamePrem, item.text)                     .setText(R.id.tvPrice, item.price)                     .setGone(R.id.ivAgreement, !item.mayAgreement)                     .setGone(R.id.tvAgreement, !item.mayAgreement)             }             MessageDTO.typeNotPremium -> {                 holder.setText(R.id.tvName, item.text)                     .setText(R.id.tvPrice, item.price)                     .setGone(R.id.ivAgreement, !item.mayAgreement)                     .setGone(R.id.tvAgreement, !item.mayAgreement)             }         }     } } <\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/202\/eb5\/da0\/202eb5da0df16c290fb622f295268a81.gif\" width=\"640\" height=\"1184\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/202\/eb5\/da0\/202eb5da0df16c290fb622f295268a81.gif\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0418 \u0432 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u044e, \u043a\u0430\u043a \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u00ab\u043f\u0440\u0435\u043c\u0438\u0443\u043c\u00bb \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043d\u0430 2 \u044f\u0447\u0435\u0439\u043a\u0438. \u0414\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u043f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430. \u041c\u0435\u0442\u043e\u0434\u043e\u043c <strong>setGridSpanSizeLookup<\/strong> \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 <strong>GridSpanSizeLookup<\/strong><\/p>\n<pre><code class=\"kotlin\">adapter.setGridSpanSizeLookup(     GridSpanSizeLookup { gridLayoutManager, viewType, position ->         when (viewType) {             MessageDTO.typePremium -> 2             else -> 1         }     } ) <\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u00ab\u043f\u0440\u0435\u043c\u0438\u0443\u043c\u00bb, \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c \u0434\u0432\u0435 \u044f\u0447\u0435\u0439\u043a\u0438, \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0434\u043d\u0443. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/46c\/79b\/e79\/46c79be792864e2901cd425d4f98053c.gif\" width=\"640\" height=\"1184\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/46c\/79b\/e79\/46c79be792864e2901cd425d4f98053c.gif\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435 \u043a \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e \u0441\u043f\u0438\u0441\u043a\u043e\u0432, \u0438 \u043b\u0435\u0433\u043a\u0443\u044e \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0447\u0430\u0441\u0442\u044f\u0445 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u044e:<\/p>\n<ul>\n<li>\n<p>\u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0441\u043f\u0438\u0441\u043a\u0430 \u0438 \u043e\u0448\u0438\u0431\u043a\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0441\u043f\u0438\u0441\u043a\u0430    <\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u00ab\u0434\u043e\u043b\u0433\u0438\u0445\u00bb \u043d\u0430\u0436\u0430\u0442\u0438\u0439    <\/p>\n<\/li>\n<li>\n<p>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u00ab\u0441\u0432\u0430\u0439\u043f\u043e\u043c\u00bb    <\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432       <\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430 <a href=\"https:\/\/github.com\/bsodKeks\/brvahExamole\" rel=\"noopener noreferrer nofollow\">\u0413\u0438\u0442\u0435<\/a><\/p>\n<p><a href=\"https:\/\/github.com\/CymChad\/BaseRecyclerViewAdapterHelper\" rel=\"noopener noreferrer nofollow\">\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430<\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/578416\/\"> https:\/\/habr.com\/ru\/articles\/578416\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u042d\u0442\u043e \u0442\u0440\u0435\u0442\u044c\u044f \u0447\u0430\u0441\u0442\u044c \u0446\u0438\u043a\u043b\u0430 \u0441\u0442\u0430\u0442\u0435\u0439 \u043f\u0440\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u043e\u0432 \u0434\u043b\u044f RecyclerView c BRVAH.<\/p>\n<p>\u041f\u0440\u043e\u0448\u043b\u044b\u0435 \u0447\u0430\u0441\u0442\u0438:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/576342\/\" rel=\"noopener noreferrer nofollow\">\u0427\u0430\u0441\u0442\u044c 1. \u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/576946\/\" rel=\"noopener noreferrer nofollow\">\u0427\u0430\u0441\u0442\u044c 2. \u041f\u0430\u0433\u0438\u043d\u0430\u0446\u0438\u044f \u0438 diffUtils \u0432 RecyclerView \u0441 BRVAH<\/a><\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u044e:<\/p>\n<ul>\n<li>\n<p>\u0410\u043d\u0438\u043c\u0430\u0446\u0438\u044e \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 layout \u0432 \u043e\u0434\u043d\u043e\u043c \u0441\u043f\u0438\u0441\u043a\u0435<\/p>\n<\/li>\n<\/ul>\n<p>\u041e\u0434\u0438\u043d \u0438\u0437 \u0447\u0430\u0441\u0442\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0431\u0438\u0437\u043d\u0435\u0441\u0430 \u0432 \u0446\u0435\u043b\u043e\u043c \u0438 \u0434\u0438\u0437\u0430\u0439\u043d\u0430 \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u2013 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435. \u0412 \u044d\u0442\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u043f\u044f\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0439<\/p>\n<ul>\n<li>\n<p>AlphaInAnimation() \u2013 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438\u0437 \u043d\u0435\u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438    <\/p>\n<\/li>\n<li>\n<p>ScaleInAnimation() \u2013 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441 \u0435\u0433\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435\u043c<\/p>\n<\/li>\n<li>\n<p>SlideInBottomAnimation() \u2013 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441\u043d\u0438\u0437\u0443    <\/p>\n<\/li>\n<li>\n<p>SlideInLeftAnimation() \u2013 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441\u043b\u0435\u0432\u0430    <\/p>\n<\/li>\n<li>\n<p>SlideInRightAnimation() \u2013 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441\u043f\u0440\u0430\u0432\u0430<\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0432\u0448\u0438\u0441\u044c \u043e\u0442 <strong>BaseAnimation<\/strong><\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 \u043a\u043e\u0434\u0430<\/p>\n<pre><code class=\"kotlin\">adapter.adapterAnimation = SlideInRightAnimation()<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u044e \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044c \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0440\u0430\u0437\u043d\u044b\u0445 layout \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430, \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f:    <\/p>\n<ul>\n<li>\n<p>\u0421\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u043f\u043e\u0434\u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430\u043c\u0438    <\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u00ab\u043f\u0440\u0435\u043c\u0438\u0443\u043c\u00bb \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f, \u043d\u0430 \u0434\u043e\u0441\u043a\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0439    <\/p>\n<\/li>\n<\/ul>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u044e \u043f\u0435\u0440\u0432\u0443\u044e \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044c. Layout, \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0442\u043e\u043b\u044c\u043a\u043e TextView, \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0421\u043e\u0437\u0434\u0430\u043b \u043d\u043e\u0432\u044b\u0439 \u0430\u0434\u0430\u043f\u0442\u0435\u0440. \u0414\u043b\u044f \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430, \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 <strong>BaseSectionQuickAdapter<\/strong>. \u041f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 \u0435\u0433\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0435\u0449\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c layout \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430. \u0415\u0449\u0435 \u0437\u043d\u0430\u0447\u0438\u043c\u043e\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u0435, \u043f\u0440\u0438 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430, DataClass \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <strong>SectionEntity<\/strong>, \u043f\u0440\u043e \u043d\u0435\u0433\u043e \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043f\u043e\u0437\u0436\u0435. \u041f\u0440\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0435\u0449\u0435 \u043c\u0435\u0442\u043e\u0434 <strong>convertHeader. <\/strong>\u0412 \u043d\u0435\u043c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 layout \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430.<\/p>\n<pre><code class=\"kotlin\">class SectionAdapter(data: MutableList&lt;NotificationWithSectionsDTO>) : BaseSectionQuickAdapter&lt;NotificationWithSectionsDTO, BaseViewHolder>(R.layout.item_section_header, R.layout.item_notification_with_image, data) {      init {         addChildClickViewIds(R.id.ivState)     }      override fun convert(holder: BaseViewHolder, item: NotificationWithSectionsDTO) {         holder.setGone(R.id.view, holder.layoutPosition == 0)             .setText(R.id.tvDateTime, item.date)             .setText(R.id.tvDsc, item.text)             .setImageResource(                 R.id.ivState,                 if (item.isRead) R.drawable.ic_delete                 else R.drawable.ic_read             )          val imageView = holder.getView&lt;ImageView>(R.id.imageView)         val context = holder.itemView.context          Glide.with(context)             .load(item.imageUrl)             .circleCrop()             .into(imageView)     }      override fun convertHeader(helper: BaseViewHolder, item: NotificationWithSectionsDTO) {         helper.setText(R.id.tvHeader, item.titleText)     } } <\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0443 \u043a DataClass\u0443. \u041e\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <strong>SectionEntity. <\/strong>\u0412 \u043d\u0435\u043c \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <strong>isHeader<\/strong> &#8212; \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u043c. \u041e\u043f\u0438\u0448\u0443 \u043d\u043e\u0432\u044b\u0439 DataClass    <\/p>\n<pre><code class=\"kotlin\">data class NotificationWithSectionsDTO(     val date: String = \"\",     val text: String = \"\",     var isRead: Boolean = false,     val imageUrl: String = \"\",     val titleText: String = \"\", ) : SectionEntity {     override val isHeader: Boolean         get() = titleText.isNotBlank() } <\/code><\/pre>\n<p>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430 \u043d\u0435 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 \u043f\u0440\u043e\u0448\u043b\u044b\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445<\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0421\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u2013 \u044d\u0442\u043e \u0447\u0430\u0441\u0442\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438, \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0435 \u0434\u0432\u0443\u043c\u044f layout. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u044e \u0431\u043e\u043b\u0435\u0435 \u043e\u0431\u0448\u0438\u0440\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. <\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e, \u0441\u0434\u0435\u043b\u0430\u044e \u043f\u043e\u0434\u043e\u0431\u0438\u0435 \u0434\u043e\u0441\u043a\u0438 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0439, \u0441 \u043e\u0431\u044b\u0447\u043d\u044b\u043c\u0438 \u0438 \u00ab\u043f\u0440\u0435\u043c\u0438\u0443\u043c\u00bb \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438.<\/p>\n<p>\u041d\u0430\u0447\u043d\u0443 \u0441 DataClass. \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0443\u043b\u044c\u0442\u0438\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u0438 \u043a\u043b\u0430\u0441\u0441 \u0434\u0430\u043d\u043d\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <strong>MultiItemEntity.<\/strong> \u0412 \u043d\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u043c\u0435\u0442\u043e\u0434 <strong>itemType<\/strong>: Int, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 \u0442\u0438\u043f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430.<\/p>\n<pre><code class=\"kotlin\">data class MessageDTO(     val text: String,     val price: String,     val image: String,     val mayAgreement: Boolean = false,     val type: Int = typeNotPremium ) : MultiItemEntity {     companion object {         const val typePremium = 0         const val typeNotPremium = 1     }      override val itemType: Int         get() = this.type } <\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u043b \u0434\u0432\u0430 \u0442\u0438\u043f\u0430 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0439 \u00ab\u043f\u0440\u0435\u043c\u0438\u0443\u043c\u00bb \u0438 \u00ab\u043d\u0435 \u043f\u0440\u0435\u043c\u0438\u0443\u043c\u00bb, <strong>itemType<\/strong> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u0445.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u043b \u0430\u0434\u0430\u043f\u0442\u0435\u0440. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 <strong>BaseMultiItemQuickAdapter<\/strong>. \u0415\u043c\u0443 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f layout\u044b, \u043e\u043d\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u043c <strong>addItemType. <\/strong>\u041c\u0435\u0442\u043e\u0434 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b itemType: Int \u0438 layoutId: Int. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e <strong>BaseQuickAdapter<\/strong>, \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u043d\u0430 \u0442\u0438\u043f\u044b. \u0414\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430, \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 convret, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u043c\u0435\u0442\u043e\u0434 \u0445\u043e\u043b\u0434\u0435\u0440\u0430 <strong>holder.itemViewType. <\/strong>\u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u0438\u043f\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u2013 \u043f\u0440\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<pre><code class=\"kotlin\">class MultiItemAdapter(data: MutableList&lt;MessageDTO>?) : BaseMultiItemQuickAdapter&lt;MessageDTO, BaseViewHolder>(data) {     init {         addItemType(MessageDTO.typeNotPremium, R.layout.item_message)         addItemType(MessageDTO.typePremium, R.layout.item_mesage_premium)     }      override fun convert(holder: BaseViewHolder, item: MessageDTO) {         val imageView = holder.getView&lt;ImageView>(R.id.ivMsg)         val context = holder.itemView.context          Glide.with(context)             .load(item.image)             .into(imageView)          when (holder.itemViewType) {             MessageDTO.typePremium -> {                 holder.setText(R.id.tvNamePrem, item.text)                     .setText(R.id.tvPrice, item.price)                     .setGone(R.id.ivAgreement, !item.mayAgreement)                     .setGone(R.id.tvAgreement, !item.mayAgreement)             }             MessageDTO.typeNotPremium -> {                 holder.setText(R.id.tvName, item.text)                     .setText(R.id.tvPrice, item.price)                     .setGone(R.id.ivAgreement, !item.mayAgreement)                     .setGone(R.id.tvAgreement, !item.mayAgreement)             }         }     } } <\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0418 \u0432 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u044e, \u043a\u0430\u043a \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u00ab\u043f\u0440\u0435\u043c\u0438\u0443\u043c\u00bb \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043d\u0430 2 \u044f\u0447\u0435\u0439\u043a\u0438. \u0414\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u043f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430. \u041c\u0435\u0442\u043e\u0434\u043e\u043c <strong>setGridSpanSizeLookup<\/strong> \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 <strong>GridSpanSizeLookup<\/strong><\/p>\n<pre><code class=\"kotlin\">adapter.setGridSpanSizeLookup(     GridSpanSizeLookup { gridLayoutManager, viewType, position ->         when (viewType) {             MessageDTO.typePremium -> 2             else -> 1         }     } ) <\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u00ab\u043f\u0440\u0435\u043c\u0438\u0443\u043c\u00bb, \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c \u0434\u0432\u0435 \u044f\u0447\u0435\u0439\u043a\u0438, \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0434\u043d\u0443. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435 \u043a \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e \u0441\u043f\u0438\u0441\u043a\u043e\u0432, \u0438 \u043b\u0435\u0433\u043a\u0443\u044e \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0447\u0430\u0441\u0442\u044f\u0445 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u044e:<\/p>\n<ul>\n<li>\n<p>\u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0441\u043f\u0438\u0441\u043a\u0430 \u0438 \u043e\u0448\u0438\u0431\u043a\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0441\u043f\u0438\u0441\u043a\u0430    <\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u00ab\u0434\u043e\u043b\u0433\u0438\u0445\u00bb \u043d\u0430\u0436\u0430\u0442\u0438\u0439    <\/p>\n<\/li>\n<li>\n<p>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u00ab\u0441\u0432\u0430\u0439\u043f\u043e\u043c\u00bb    <\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432       <\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430 <a href=\"https:\/\/github.com\/bsodKeks\/brvahExamole\" rel=\"noopener noreferrer nofollow\">\u0413\u0438\u0442\u0435<\/a><\/p>\n<p><a href=\"https:\/\/github.com\/CymChad\/BaseRecyclerViewAdapterHelper\" rel=\"noopener noreferrer nofollow\">\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430<\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/578416\/\"> https:\/\/habr.com\/ru\/articles\/578416\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-421307","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/421307","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=421307"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/421307\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=421307"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=421307"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=421307"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}