File tree 3 files changed +17
-2
lines changed
java/com/spring/androidconductormvvmsample
3 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -47,5 +47,9 @@ class DetailController : Controller() {
47
47
view.btnPush.clicks().subscribe({
48
48
flowControl.push(DetailController ())
49
49
})
50
+
51
+ view.btnClear.clicks().subscribe({
52
+ viewModel.clearData()
53
+ })
50
54
}
51
55
}
Original file line number Diff line number Diff line change @@ -17,8 +17,8 @@ import javax.inject.Inject
17
17
*/
18
18
class SimpleViewModel {
19
19
@Inject
20
- lateinit var service: GithubService
21
- var user : User ? = null
20
+ protected lateinit var service: GithubService
21
+ private var user : User ? = null
22
22
23
23
constructor () {
24
24
MainActivity .graph.inject(this )
@@ -31,4 +31,9 @@ class SimpleViewModel {
31
31
return service.getMyProfile().doOnSuccess { success -> this .user = success }.subscribeOn(Schedulers .newThread())
32
32
}
33
33
}
34
+
35
+ fun clearData () {
36
+ user = null
37
+ }
38
+
34
39
}
Original file line number Diff line number Diff line change 41
41
android : layout_height =" wrap_content"
42
42
android : text =" Click Me to push new controller" />
43
43
44
+ <Button
45
+ android : id =" @+id/btnClear"
46
+ android : layout_width =" match_parent"
47
+ android : layout_height =" wrap_content"
48
+ android : text =" Click me to clear user cache" />
49
+
44
50
</LinearLayout >
You can’t perform that action at this time.
0 commit comments