Skip to content

Commit 2c76334

Browse files
committed
Update Readme
1 parent e3fab2f commit 2c76334

File tree

8 files changed

+31
-38
lines changed

8 files changed

+31
-38
lines changed

README.md

Lines changed: 31 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,36 @@
1-
# Modular²Recycler
1+
<img src="docs/art/Header.png" alt="Header">
22

3-
Modular²Recycler is a `RecyclerView.Adapter` that is modular *squared*.
3+
### Modular²Recycler is a `RecyclerView.Adapter` that is modular *squared*.
4+
5+
It also adds extra features:
6+
- OnItem(Long)ClickListener
7+
- Headers
8+
- Swipe to dismiss with undo
9+
- Drag and drop.
10+
11+
<img src="docs/art/Item_click.gif" alt="Item click" width="200px">
12+
<img src="docs/art/Item_long_click.gif" alt="Item click" width="200px">
13+
<img src="docs/art/Swipe.gif" alt="Item click" width="200px">
14+
<img src="docs/art/Drag_drop.gif" alt="Item click" width="200px">
415

516
## Design Pattern
617

7-
This library uses the approach of [Modular design](https://en.wikipedia.org/wiki/Modular_design), in which a system is subdivided into modular, reusable components. It makes use of both the [composition](https://en.wikipedia.org/wiki/Object_composition) and [aggregation](https://en.wikipedia.org/wiki/Object_composition#Aggregation) pattern. A detailed explanation about the architecture of this library can be read [here](https://robbesneyders.github.io/Modular2Recycler).
18+
This library uses the approach of [Modular design](https://en.wikipedia.org/wiki/Modular_design), in which a system is subdivided into modular, reusable components.
19+
A detailed explanation about the architecture of this library can be read [here](https://robbesneyders.github.io/Modular2Recycler).
820

921
The ² in Modular²Recycler denotes the modularity of the adapter on two separate levels.
1022

1123
### First Level
1224

13-
Instead of creating one huge adapter to populate a `RecyclerView` with our data, we create an __AdapterModule__ for each different viewtype. The composition (or better: aggregation) of these __AdapterModules__ is handled by this library.
14-
15-
<img src="docs/art/Modular_level_1.png" alt="Modular level 1" width="300">
16-
Figure 1: Aggregation of __AdapterModules__ into ModularAdapter.
25+
Instead of creating one huge adapter to populate a `RecyclerView` with data, one __AdapterModule__ is created for each different viewtype.
1726

18-
### Second level
27+
<img src="docs/art/Modular_level_1.png" alt="Modular level 1" width="500">
1928

20-
On the second level, these __AdapterModules__ are modular themselves. They consist of a fundament: the class __AdapterModule__, which they should inherit from. Reusable components can be added to this fundament to add certain functionalities. These reusable components are offered by this library in the form of __Plugins__ which are implemented as `Interfaces`.
29+
### Second Level
2130

22-
<img src="docs/art/Modular_level_2.png" alt="Modular level 2" width="250">
23-
Figure 2: Composition of __Plugins__ into __AdapterModule__.
31+
Extra funcionality can be added to these __AdapterModules__ by implementing __plugins__ provided by this library.
2432

25-
#### Available plugins
26-
27-
The plugins offered by this library at the moment are:
28-
- OnItemClick
29-
- OnItemLongClick
30-
- Headers
31-
- Swipe to remove/archive/any action
32-
- Undo
33-
- Drag and drop
34-
- Stay within section
33+
<img src="docs/art/Modular_level_2.png" alt="Modular level 2" width="300">
3534

3635
## Dependencies
3736

@@ -61,7 +60,9 @@ dependencies {
6160
This library does a lot of the necessary work for you. Just follow these steps:
6261
*Example based on available example app.*
6362

64-
__1.__ For each ViewType
63+
64+
65+
#### 1. For each ViewType
6566
- Create an item by implementing __ModularItem__
6667
- Create a module by extending __AdapterModule__
6768

@@ -79,10 +80,6 @@ public class Pokemon implements ModularItem {
7980

8081
class PokemonModule extends AdapterModule<PokemonViewHolder, Pokemon> {
8182

82-
public PokemonModule(ModularAdapter adapter) {
83-
super(adapter);
84-
}
85-
8683
@Override
8784
public PokemonViewHolder onCreateViewHolder(ViewGroup parent) {
8885
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.recycler_row, parent, false);
@@ -126,10 +123,6 @@ public class Header implements ModularItem {
126123

127124
class HeaderModule extends AdapterModule<HeaderModule.HeaderViewHolder, Header> {
128125

129-
HeaderModule(ModularAdapter adapter) {
130-
super(adapter);
131-
}
132-
133126
@Override
134127
public HeaderViewHolder onCreateViewHolder(ViewGroup parent) {
135128
View headerView = LayoutInflater.from(parent.getContext()).inflate(R.layout.recycler_header, parent, false);
@@ -153,7 +146,7 @@ class HeaderModule extends AdapterModule<HeaderModule.HeaderViewHolder, Header>
153146

154147
```
155148

156-
__2.__ Add the desired functionality to your module by implementing the corresponding __plugins__.
149+
#### 2. Add the desired functionality to your module by implementing the corresponding __plugins__.
157150

158151
```java
159152
public class PokemonModule extends AdapterModule<PokemonViewHolder, Pokemon>
@@ -174,9 +167,9 @@ public class PokemonModule extends AdapterModule<PokemonViewHolder, Pokemon>
174167
}
175168
```
176169

177-
__4.__ Create an instance of the ModularAdapter in your `Activity`
170+
#### 3. Create an instance of the ModularAdapter in your `Activity`
178171

179-
*There is no need to extend the ModularAdapter class!*
172+
*There is no need to extend the ModularAdapter class unless you want to add extra functionality.*
180173

181174
```java
182175
List<Pokemon> pokemonList = Pokedex.getAllPokemonAlphabetic();
@@ -188,18 +181,18 @@ adapter = new ModularAdapterBuilder<>(recyclerView, list)
188181
.build();
189182
```
190183

191-
__5.__ Create an instance of the __AdapterModules__ you want to add and pass in the created instance of __ModularAdapter__
184+
#### 4. Create an instance of the __AdapterModules__ you want to add and bind them to the created instance of __ModularAdapter__
192185

193186
```java
194-
new PokemonModule(adapter);
195-
new HeaderModule(adapter);
187+
new PokemonModule().bindToAdapter(adapter);
188+
new HeaderModule().bindToAdapter(adapter);
196189
```
197190

198191
## Example App
199192

200193
PokéApp is an example app to demonstrate the use of this library.
201-
- [Code](app)
202-
- [Available on Play Store](https://play.google.com/store/apps/details?id=com.cuttingedge.pokeApp).
194+
- [Source code](app)
195+
- [Available on Play Store](https://play.google.com/store/apps/details?id=com.cuttingedge.pokeapp).
203196

204197
[![UndoRecycler](http://i.imgur.com/jFQTroq.gif)](http://imgur.com/jFQTroq) [![UndoRecyclerAlphabetic](http://i.imgur.com/5bgXPR2.gif)](http://imgur.com/5bgXPR2)
205198

docs/art/Drag_drop.gif

2.62 MB
Loading

docs/art/Header.png

39.9 KB
Loading

docs/art/Item_click.gif

1.49 MB
Loading

docs/art/Item_long_click.gif

1.88 MB
Loading

docs/art/Modular_level_1.png

-10.2 KB
Loading

docs/art/Modular_level_2.png

1.74 KB
Loading

docs/art/Swipe.gif

2.64 MB
Loading

0 commit comments

Comments
 (0)