Skip to content

Commit a24ffdf

Browse files
author
Daniel Novak
committed
Add Google Play link
1 parent 682e90f commit a24ffdf

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ You can execute asynchronous tasks in this ViewModel instance and this class is
1010

1111
![](website/static/viewmodel_architecture.png)
1212

13-
<b>How to implement</b>:
13+
How to implement
14+
--------
1415

1516
1. Create an interface for your <b>View</b> by extending [IView](library/src/main/java/eu/inloop/viewmodel/IView.java). We will call it IUserListView for this example.
1617

@@ -41,7 +42,8 @@ You can execute asynchronous tasks in this ViewModel instance and this class is
4142
}
4243
```
4344

44-
<b>How to use</b>:
45+
How to use
46+
--------
4547

4648
You can forward user interaction from the View into the ViewModel simply by calling:
4749

@@ -53,10 +55,18 @@ The same goes for the opposite direction, when your asynchronous operation in th
5355

5456
```java
5557
if (getView() != null) {
56-
getView().showUsers(userList);
58+
getView().showUsers(userList);
5759
}
5860
```
5961

62+
Your Fragment argument Bundle and Activity intent Bundle is forwarded to the ViewModel's onCreate method, which you can override to read the initial arguments for the ViewModel.
63+
64+
```java
65+
public void onCreate(Bundle arguments, Bundle savedInstanceState) {
66+
long userId = arguments.getInt("user_id", -1);
67+
}
68+
```
69+
6070
<b>How does it work?</b>
6171

6272
A unique global ID is generated for the first time your Fragment or Activity is shown. This ID is passed on during orientation changes. Opening another instance of the same Fragment or Activity will result in a different ID. The ID is unique screen identifier. A ViewModel class is created and bound to this ID. The corresponding ViewModel instance is attached to your Fragment or Activity after an orientation change or if you return to the fragment in the back stack.
@@ -95,5 +105,7 @@ or Maven:
95105
<version>0.2</version>
96106
</dependency>
97107
```
108+
Build and study sample application from source code or download from Google Play.<br/>
109+
[![](website/static/google_play.png)](https://play.google.com/store/apps/details?id=eu.inloop.viewmodel.sample)
98110

99111
<b>Development status:</b> Used internally at company on some production applications. Library is under development and API changes might occur anytime. But it should be usuable at this point without any big issues (like memory leaks).

website/static/google_play.png

10.2 KB
Loading

0 commit comments

Comments
 (0)