From 72a7296c6abfd4334b387aea4a843cfe34302b7e Mon Sep 17 00:00:00 2001 From: Drakeet Date: Mon, 9 Dec 2019 22:38:29 +0800 Subject: [PATCH] Prepare for release 4.1.0 --- CHANGELOG.md | 5 +++++ README.md | 38 ++++++++++++++++++++------------------ build.gradle | 4 ++-- 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66842a10..407a31ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # MultiType Releases +### Version 4.1.0 - Dec 9, 2019 + +- Add `ItemViewDelegate` & `onCreateViewHolder(context, _)` (#292) +- Kotlin 1.3.61 + ### Version 4.0.0 - Sep 7, 2019 - Migrate to com.drakeet group (#267) diff --git a/README.md b/README.md index dc181145..9af5d9ce 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ An Android library makes it easier and more flexible to create multiple types of [![Build Status](https://travis-ci.org/drakeet/MultiType.svg?branch=3.x)](https://travis-ci.org/drakeet/MultiType) [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/drakeet/MultiType/blob/master/LICENSE) -![maven-central](https://img.shields.io/maven-central/v/me.drakeet.multitype/multitype.svg) +![maven-central](https://img.shields.io/maven-central/v/com.drakeet.multitype/multitype.svg) ![jetbrains-plugin](https://img.shields.io/jetbrains/plugin/v/9202-a8translate.svg) Previously, when we need to develop a complex RecyclerView / ListView, it is difficult and @@ -23,7 +23,7 @@ _In addition, since 4.0.0 we have migrated to fully build with Kotlin. If you do ```groovy dependencies { - implementation 'com.drakeet.multitype:multitype:4.0.0' + implementation 'com.drakeet.multitype:multitype:4.1.0' } ``` @@ -37,20 +37,22 @@ data class Foo( ) ``` -#### Step 2. Create a class extends `ItemViewBinder`, for example: +#### Step 2. Create a class extends `ItemViewDelegate`, for example: ```kotlin -class FooViewBinder: ItemViewBinder() { +class FooViewDelegate: ItemViewDelegate() { - override fun onCreateViewHolder(inflater: LayoutInflater, parent: ViewGroup): ViewHolder { - return ViewHolder(inflater.inflate(R.layout.item_foo, parent, false)) + override fun onCreateViewHolder(context: Context, parent: ViewGroup): ViewHolder { + // If you want a LayoutInflater parameter instead of a Context, + // you can use ItemViewBinder as the parent of this class. + return ViewHolder(FooView(context)) } override fun onBindViewHolder(holder: ViewHolder, item: Foo) { holder.fooView.text = item.value - Log.d("ItemViewBinder API", "position: ${getPosition(holder)}") - Log.d("ItemViewBinder API", "items: $adapterItems") - Log.d("ItemViewBinder API", "adapter: $adapter") + Log.d("ItemViewDelegate API", "position: ${getPosition(holder)}") + Log.d("ItemViewDelegate API", "items: $adapterItems") + Log.d("ItemViewDelegate API", "adapter: $adapter") Log.d("More", "Context: ${holder.itemView.context}") } @@ -73,9 +75,9 @@ class SampleActivity : AppCompatActivity() { setContentView(R.layout.activity_list) val recyclerView = findViewById(R.id.list) - adapter.register(TextItemViewBinder()) - adapter.register(ImageItemViewBinder()) - adapter.register(RichItemViewBinder()) + adapter.register(TextItemViewDelegate()) + adapter.register(ImageItemViewDelegate()) + adapter.register(RichItemViewDelegate()) recyclerView.adapter = adapter val textItem = TextItem("world") @@ -101,19 +103,19 @@ class SampleActivity : AppCompatActivity() { ```kotlin adapter.register(Data::class).to( - DataType1ViewBinder(), - DataType2ViewBinder() + DataType1ViewDelegate(), + DataType2ViewDelegate() ).withKotlinClassLinker { _, data -> when (data.type) { - Data.TYPE_2 -> DataType2ViewBinder::class - else -> DataType1ViewBinder::class + Data.TYPE_2 -> DataType2ViewDelegate::class + else -> DataType1ViewDelegate::class } } ``` See `OneDataToManyActivity`, `OneToManyFlow` and `OneToManyEndpoint` for more details. -**More methods that you can override from [ItemViewBinder](library/src/main/kotlin/me/drakeet/multitype/ItemViewBinder.kt)**: +**More methods that you can override from [ItemViewDelegate](library/src/main/kotlin/me/drakeet/multitype/ItemViewDelegate.kt)**: ```kotlin open fun onBindViewHolder(holder: VH, item: T, payloads: List) @@ -128,7 +130,7 @@ open fun onViewDetachedFromWindow(holder: VH) - **[drakeet/MultiTypeTemplates](https://github.com/drakeet/MultiTypeTemplates)** - An intellij idea plugin for Android to generate `MultiType` `Item` and `ItemViewBinder` easily. + An intellij idea plugin for Android to generate `MultiType` `Item` and `ItemViewDelegate` easily. diff --git a/build.gradle b/build.gradle index 4b00ca01..5c956e80 100644 --- a/build.gradle +++ b/build.gradle @@ -21,8 +21,8 @@ buildscript { ext.annotationVersion = '1.1.0' ext.appcompatVersion = '1.0.2' ext.buildConfig = [ - 'versionCode': 405, - 'versionName': "4.0.0", + 'versionCode': 410, + 'versionName': "4.1.0", 'compileSdkVersion': 29, 'minSdkVersion': 14, 'targetSdkVersion': 28