From 2c0621b5583e280cf3e22f54f64d4b709594b501 Mon Sep 17 00:00:00 2001 From: Drakeet Date: Tue, 24 Dec 2019 21:13:38 +0800 Subject: [PATCH] Prepare for release 4.2.0 --- CHANGELOG.md | 4 ++++ README.md | 23 ++++++++++++++++++++++- build.gradle | 4 ++-- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3a63fee..eaf0d518 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # MultiType Releases +### Version 4.2.0 - Dec 24, 2019 + +- Add `ViewDelegate` that does not require `ViewHolder` (#296) + ### Version 4.1.1 - Dec 11, 2019 - Fix binary incompatibility about `ItemViewBinder` (#294) diff --git a/README.md b/README.md index c6d81fb4..621a03d4 100644 --- a/README.md +++ b/README.md @@ -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.1.1' + implementation 'com.drakeet.multitype:multitype:4.2.0' } ``` @@ -62,6 +62,27 @@ class FooViewDelegate: ItemViewDelegate() { } ``` +##### Or if you are using a custom View instead of XML layout, you can use `ViewDelegate`: + +> The `ViewDelegate` is a simple `ItemViewDelegate` that does not require to declare and provide a `RecyclerView.ViewHolder`. + +```kotlin +class FooViewDelegate : ViewDelegate() { + + override fun onCreateView(context: Context): RichView { + return FooView(context).apply { layoutParams = LayoutParams(MATCH_PARENT, WRAP_CONTENT) } + } + + override fun onBindView(view: FooView, item: Foo) { + view.imageView.setImageResource(item.imageResId) + view.textView.text = item.text + // Or bind the data in the FooView by calling view.setFoo(item) + } +} +``` + +(See [`RichViewDelegate`](sample/src/main/kotlin/com/drakeet/multitype/sample/normal/RichViewDelegate.kt) & [`RichView`](sample/src/main/kotlin/com/drakeet/multitype/sample/normal/RichView.kt) examples for more details) + #### Step 3. `register` your types and setup your `RecyclerView`, for example: ```kotlin diff --git a/build.gradle b/build.gradle index 8c20d31c..c66b9665 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': 411, - 'versionName': "4.1.1", + 'versionCode': 420, + 'versionName': "4.2.0", 'compileSdkVersion': 29, 'minSdkVersion': 14, 'targetSdkVersion': 28