Skip to content

Commit 893132d

Browse files
authored
Update README.md
1 parent 196dc2c commit 893132d

1 file changed

Lines changed: 18 additions & 31 deletions

File tree

README.md

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,13 @@ Groupie plays best with Kotlin and Kotlin Android extensions. Never write a View
1313
You can also use Groupie with Java and your existing ViewHolders.
1414

1515
```gradle
16-
compile 'com.xwray:groupie:2.0.0-alpha2'
16+
compile 'com.xwray:groupie:2.0.0'
1717
```
1818

1919
Groupie also supports Android's [data binding](https://developer.android.com/topic/libraries/data-binding/index.html) to generate view holders. [Setup here.](#data-binding)
2020

2121
```gradle
22-
compile 'com.xwray:groupie-databinding:2.0.0-alpha2'
23-
```
24-
The last stable release ONLY supported data binding. It was:
25-
```gradle
26-
compile 'com.xwray:groupie:1.1.1'
22+
compile 'com.xwray:groupie-databinding:2.0.0'
2723
```
2824

2925
Which one to choose? It's up to you and what your project already uses. You can even use Kotlin and data binding together.[<sup>*</sup>](#kotlin-and-data-binding) Or all your existing hand-written Java ViewHolders, and one new Kotlin item to try it out. Go crazy!
@@ -60,30 +56,15 @@ section.removeHeader(); // results in a remove event for 1 item in the adapter,
6056
```
6157

6258
There are a few simple implementations of Groups within the library:
63-
- `Section`, a list of body content with an optional header group and footer group.
59+
- `Section`, a list of body content with an optional header group and footer group. It supports diffing
6460
- `ExpandableGroup`, a single parent group with a list of body content that can be toggled hidden or shown.
6561
- `UpdatingGroup`, a list of items which can diff its previous and new contents and animate moves, updates and other changes
6662

67-
Groups are flexible and composable. They can be combined and nested to arbitrary depth. For example, you could make an UpdatingSection by adding a single UpdatingGroup to the content of a Section.
68-
69-
```java
70-
public class UpdatingSection extends Section {
71-
private final UpdatingGroup updatingGroup;
72-
73-
public UpdatingSection() {
74-
setHeader(new HeaderItem("Updating section!");
75-
updatingGroup = new UpdatingGroup();
76-
}
77-
78-
public void update(List<Item> list) {
79-
updatingGroup.update(list);
80-
}
81-
}
82-
```
63+
Groups are flexible and composable. They can be combined and nested to arbitrary depth.
8364

8465
Life is messy, so groups are designed so that making new ones and defining their behavior is easy. You should make many small, simple, custom groups as the need strikes you.
8566

86-
You can implement the `Group` interface directly if you want. However, in most cases, you should extend the base implementation, `NestedGroup`. NestedGroup provides support for arbitrary nesting of groups, registering/unregistering listeners, and fine-grained change notifications to support animations and updating the adapter.
67+
You can implement the `Group` interface directly if you want. However, in most cases, you should extend `Section` or the base implementation, `NestedGroup`. Section supports common RV paradigms like diffing, headers, footers, and placeholders. NestedGroup provides support for arbitrary nesting of groups, registering/unregistering listeners, and fine-grained change notifications to support animations and updating the adapter.
8768

8869
## Items
8970

@@ -94,15 +75,15 @@ Groupie abstracts away the complexity of multiple item view types. Each Item de
9475
The `Item` class gives you simple callbacks to bind your model object to the generated fields. Because of Kotlin Android extensions, there's no need to write a view holder.
9576

9677
```kotlin
97-
import kotlinx.android.synthetic.main.song.view.*
78+
import kotlinx.android.synthetic.main.song.*
9879

9980
class SongItem constructor(private val song: Song) : Item<ViewHolder>() {
10081

10182
override fun getLayout() = R.layout.song
10283

10384
override fun bind(viewHolder: ViewHolder, position: Int) {
104-
viewHolder.itemView.title.text = song.title
105-
viewHolder.itemView.title.artist = song.artist
85+
viewHolder.title.text = song.title
86+
viewHolder.title.artist = song.artist
10687
}
10788
}
10889
```
@@ -153,7 +134,7 @@ apply plugin: 'kotlin-android'
153134
apply plugin: 'kotlin-android-extensions'
154135
155136
buildscript {
156-
ext.kotlin_version = '1.1.1'
137+
ext.kotlin_version = '1.2.10'
157138
repositories {
158139
jcenter()
159140
}
@@ -163,15 +144,21 @@ buildscript {
163144
}
164145
}
165146
147+
// IMPORTANT! Enables view caching in viewholders.
148+
// See: https://github.com/Kotlin/KEEP/blob/master/proposals/android-extensions-entity-caching.md
149+
androidExtensions {
150+
experimental = true
151+
}
152+
166153
dependencies {
167-
compile 'com.xwray:groupie:2.0.0-alpha2'
154+
compile 'com.xwray:groupie:2.0.0'
168155
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
169156
}
170157
```
171158

172159
Remember to include
173160
```kotlin
174-
import kotlinx.android.synthetic.main.my_item_layout.view.*
161+
import kotlinx.android.synthetic.main.my_item_layout.*
175162
```
176163
in the corresponding Item class for generated view references.
177164

@@ -187,7 +174,7 @@ android {
187174
}
188175
189176
dependencies {
190-
compile 'com.xwray:groupie-databinding:2.0.0-alpha2'
177+
compile 'com.xwray:groupie-databinding:2.0.0'
191178
}
192179
```
193180

0 commit comments

Comments
 (0)