[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-7243":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":16,"stars30d":16,"stars90d":16,"forks30d":16,"starsTrendScore":16,"compositeScore":17,"rankGlobal":10,"rankLanguage":10,"license":18,"archived":19,"fork":19,"defaultBranch":20,"hasWiki":19,"hasPages":19,"topics":21,"createdAt":10,"pushedAt":10,"updatedAt":28,"readmeContent":29,"aiSummary":30,"trendingCount":16,"starSnapshotCount":16,"syncStatus":31,"lastSyncTime":32,"discoverSource":33},7243,"MultiType","drakeet\u002FMultiType","drakeet","Flexible multiple types for Android RecyclerView.","",null,"Kotlin",5761,746,118,10,0,39.62,"Apache License 2.0",false,"master",[22,23,24,25,26,27],"android-library","multitype","one-to-many","one2many","recyclerview","recyclerview-multi-type","2026-06-12 02:01:36","# MultiType\nEasier and more flexible to create multiple types for Android RecyclerView.\n\n[![Build Status](https:\u002F\u002Ftravis-ci.org\u002Fdrakeet\u002FMultiType.svg?branch=3.x)](https:\u002F\u002Ftravis-ci.org\u002Fdrakeet\u002FMultiType)\n[![License](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flicense-Apache%202.0-blue.svg)](https:\u002F\u002Fgithub.com\u002Fdrakeet\u002FMultiType\u002Fblob\u002Fmaster\u002FLICENSE)\n![maven-central](https:\u002F\u002Fimg.shields.io\u002Fmaven-central\u002Fv\u002Fcom.drakeet.multitype\u002Fmultitype.svg)\n![jetbrains-plugin](https:\u002F\u002Fimg.shields.io\u002Fjetbrains\u002Fplugin\u002Fv\u002F9202-a8translate.svg)\n\nPreviously, when we need to develop a complex RecyclerView \u002F ListView, it is difficult and\ntroublesome work. We should override the `getItemViewType()` of `RecyclerView.Adapter` , add some types, and create some `ViewHolder`s relating to those types. Once we need to add a new item type, we have to go to the original adapter file and modify some old codes carefully, \nand these adapter classes will get more complicated.\n\nNowadays, I created a new intuitive and flexible way to easily create complex RecyclerViews,\n**with the MultiType library, we could insert a new item type without changing any old adapter codes and make them more readable.**\n\n## Getting started\n\nIn your `build.gradle`:\n\n_MultiType has been rebuilt based on [AndroidX](https:\u002F\u002Fdeveloper.android.com\u002Fjetpack\u002Fandroidx\u002F). If you are still using the android support library, please use `me.drakeet.multitype:multitype:3.4.4` and `me.drakeet.multitype:multitype-kotlin:3.4.4`._\n\n_In addition, since 4.0.0 we have migrated to fully build with Kotlin. If you don't want to use Kotlin, you can use the last stable version `me.drakeet.multitype:multitype:3.5.0` and see [3.x](https:\u002F\u002Fgithub.com\u002Fdrakeet\u002FMultiType\u002Ftree\u002F3.x)._\n\n```groovy\ndependencies {\n  implementation 'com.drakeet.multitype:multitype:4.3.0'\n}\n```\n\n## Usage\n\n#### Step 1. Create a Kotlin `class` or `data class`, for example:\n\n```kotlin\ndata class Foo(\n  val value: String\n)\n```\n\n#### Step 2. Create a class extends `ItemViewDelegate\u003CT, VH : ViewHolder>`, for example:\n\n```kotlin\nclass FooViewDelegate: ItemViewDelegate\u003CFoo, FooViewDelegate.ViewHolder>() {\n\n  override fun onCreateViewHolder(context: Context, parent: ViewGroup): ViewHolder {\n    \u002F\u002F If you want a LayoutInflater parameter instead of a Context,\n    \u002F\u002F you can use ItemViewBinder as the parent of this class.\n    return ViewHolder(FooView(context))\n  }\n\n  override fun onBindViewHolder(holder: ViewHolder, item: Foo) {\n    holder.fooView.text = item.value\n\n    Log.d(\"ItemViewDelegate API\", \"position: ${holder.bindingAdapterPosition}\")\n    Log.d(\"ItemViewDelegate API\", \"items: $adapterItems\")\n    Log.d(\"ItemViewDelegate API\", \"adapter: $adapter\")\n    Log.d(\"More\", \"Context: ${holder.itemView.context}\")\n  }\n\n  class ViewHolder(itemView : View): RecyclerView.ViewHolder(itemView) {\n    val fooView: TextView = itemView.findViewById(R.id.foo)\n  }\n}\n```\n\n##### Or if you are using a custom View instead of XML layout, you can use `ViewDelegate`:\n\n> The `ViewDelegate` is a simple `ItemViewDelegate` that does not require to declare and provide a `RecyclerView.ViewHolder`.\n\n```kotlin\nclass FooViewDelegate : ViewDelegate\u003CFoo, FooView>() {\n\n  override fun onCreateView(context: Context): FooView {\n    return FooView(context).apply { layoutParams = LayoutParams(MATCH_PARENT, WRAP_CONTENT) }\n  }\n\n  override fun onBindView(view: FooView, item: Foo) {\n    view.imageView.setImageResource(item.imageResId)\n    view.textView.text = item.text\n\n    view.textView.text = \"\"\"\n      |${item.text}\n      |viewHolder: ${view.holder}\n      |layoutPosition: ${view.layoutPosition}\n      |absoluteAdapterPosition: ${view.absoluteAdapterPosition}\n      |bindingAdapterPosition: ${view.bindingAdapterPosition}\n    \"\"\".trimMargin()\n  }\n}\n```\n\n(See [`RichViewDelegate`](sample\u002Fsrc\u002Fmain\u002Fkotlin\u002Fcom\u002Fdrakeet\u002Fmultitype\u002Fsample\u002Fnormal\u002FRichViewDelegate.kt) & [`RichView`](sample\u002Fsrc\u002Fmain\u002Fkotlin\u002Fcom\u002Fdrakeet\u002Fmultitype\u002Fsample\u002Fnormal\u002FRichView.kt) examples for more details)\n\n#### Step 3. `register` your types and setup your `RecyclerView`, for example:\n\n```kotlin\nclass SampleActivity : AppCompatActivity() {\n\n  private val adapter = MultiTypeAdapter()\n  private val items = ArrayList\u003CAny>()\n\n  override fun onCreate(savedInstanceState: Bundle?) {\n    super.onCreate(savedInstanceState)\n    setContentView(R.layout.activity_list)\n    val recyclerView = findViewById\u003CRecyclerView>(R.id.list)\n\n    adapter.register(TextItemViewDelegate())\n    adapter.register(ImageItemViewDelegate())\n    adapter.register(RichItemViewDelegate())\n    recyclerView.adapter = adapter\n\n    val textItem = TextItem(\"world\")\n    val imageItem = ImageItem(R.mipmap.ic_launcher)\n    val richItem = RichItem(\"小艾大人赛高\", R.drawable.img_11)\n\n    for (i in 0..19) {\n      items.add(textItem)\n      items.add(imageItem)\n      items.add(richItem)\n    }\n    adapter.items = items\n    adapter.notifyDataSetChanged()\n  }\n}\n```\n\n**That's all, you're good to go!**\n\n## Advanced usage \n\n**One to many**:  \n\n```kotlin\nadapter.register(Data::class).to(\n  DataType1ViewDelegate(),\n  DataType2ViewDelegate()\n).withKotlinClassLinker { _, data ->\n  when (data.type) {\n    Data.TYPE_2 -> DataType2ViewDelegate::class\n    else -> DataType1ViewDelegate::class\n  }\n}\n```\n\nSee `OneDataToManyActivity`, `OneToManyFlow` and `OneToManyEndpoint` for more details.\n\n**More methods that you can override from [ItemViewDelegate](library\u002Fsrc\u002Fmain\u002Fkotlin\u002Fme\u002Fdrakeet\u002Fmultitype\u002FItemViewDelegate.kt)**:\n\n```kotlin\nopen fun onBindViewHolder(holder: VH, item: T, payloads: List\u003CAny>)\nopen fun getItemId(item: T): Long\nopen fun onViewRecycled(holder: VH)\nopen fun onFailedToRecycleView(holder: VH): Boolean\nopen fun onViewAttachedToWindow(holder: VH)\nopen fun onViewDetachedFromWindow(holder: VH)\n```\n\n## Android Studio Plugin\n\n- **[drakeet\u002FMultiTypeTemplates](https:\u002F\u002Fgithub.com\u002Fdrakeet\u002FMultiTypeTemplates)**\n\n An intellij idea plugin for Android to generate `MultiType` `Item` and `ItemViewDelegate` easily.\n\n\u003Cimg src=\"http:\u002F\u002Fww4.sinaimg.cn\u002Flarge\u002F86e2ff85gw1f8yj0sejd6j21340ben1s.jpg\" width=640\u002F>\n\n## Screenshots\n\nPages created with MultiType:\n\n\u003Cimg src=\"https:\u002F\u002Fi.loli.net\u002F2018\u002F06\u002F05\u002F5b16aa7d5968b.png\" width=216\u002F>\u003Cimg src=\"https:\u002F\u002Fi.loli.net\u002F2018\u002F06\u002F05\u002F5b16aa7d83aec.png\" width=216\u002F>\u003Cimg src=\"https:\u002F\u002Fi.loli.net\u002F2018\u002F06\u002F05\u002F5b16aa7fbbc87.png\" width=216\u002F>\n\n\u003Cimg src=\"https:\u002F\u002Fi.loli.net\u002F2018\u002F06\u002F05\u002F5b16aa83af0f7.png\" width=216\u002F>\u003Cimg src=\"https:\u002F\u002Fi.loli.net\u002F2018\u002F06\u002F05\u002F5b16aa843e488.png\" width=216\u002F>\u003Cimg src=\"https:\u002F\u002Fi.loli.net\u002F2018\u002F06\u002F05\u002F5b16aa86c52e7.png\" width=216\u002F>\n\n\u003Cimg src=\"https:\u002F\u002Fi.loli.net\u002F2017\u002F10\u002F20\u002F59e95e4c78f5b.png\" width=270\u002F> \u003Cimg src=\"https:\u002F\u002Fi.loli.net\u002F2017\u002F10\u002F20\u002F59e95e4c8243c.png\" width=270\u002F>\n\nLicense\n-------\n\n    Copyright (c) 2016-present. Drakeet Xu\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http:\u002F\u002Fwww.apache.org\u002Flicenses\u002FLICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n","MultiType 是一个用于 Android RecyclerView 的灵活多类型库。它通过提供一种直观且灵活的方式来简化复杂列表的开发，允许开发者在不修改原有适配器代码的情况下轻松添加新的条目类型，从而提高代码的可读性和维护性。该库支持 Kotlin 语言，并基于 AndroidX 构建，适用于需要展示多种不同类型数据项的 RecyclerView 场景，如社交应用的消息流、新闻聚合应用的文章列表等。",2,"2026-06-11 03:11:21","top_language"]