@@ -52,41 +52,25 @@ open class PortalFragment : Fragment {
52
52
private var initialContext: Any? = null
53
53
54
54
private val viewModel: PortalViewModel by viewModels()
55
- private var providedViewModel: PortalViewModel ? = null
56
55
57
56
constructor ()
58
57
59
58
constructor (portal: Portal ? ) {
60
59
this .portal = portal
61
60
}
62
61
63
- constructor (portal: Portal ? , viewModel: PortalViewModel ) {
64
- this .portal = portal
65
- this .providedViewModel = viewModel
66
- }
67
-
68
62
constructor (portal: Portal ? , onBridgeAvailable: ((bridge: Bridge ) -> Unit )? ) {
69
63
this .portal = portal
70
64
this .onBridgeAvailable = onBridgeAvailable
71
65
}
72
66
73
- constructor (portal: Portal ? , viewModel: PortalViewModel , onBridgeAvailable: ((bridge: Bridge ) -> Unit )? ) : super () {
74
- this .portal = portal
75
- this .providedViewModel = viewModel
76
- this .onBridgeAvailable = onBridgeAvailable
77
- }
78
-
79
67
/* *
80
68
* Extends the Android Fragment `onCreate` lifecycle event.
81
69
*/
82
70
override fun onCreate (savedInstanceState : Bundle ? ) {
83
71
super .onCreate(savedInstanceState)
84
72
portal?.let { portal ->
85
- if (providedViewModel != null ) {
86
- providedViewModel?.state?.value = portal
87
- } else {
88
- viewModel.state.value = portal
89
- }
73
+ viewModel.state.value = portal
90
74
}
91
75
}
92
76
@@ -109,14 +93,8 @@ open class PortalFragment : Fragment {
109
93
*/
110
94
override fun onViewCreated (view : View , savedInstanceState : Bundle ? ) {
111
95
super .onViewCreated(view, savedInstanceState)
112
- if (providedViewModel != null ) {
113
- providedViewModel?.state?.value?.let {
114
- portal = it
115
- }
116
- } else {
117
- viewModel.state.value?.let {
118
- portal = it
119
- }
96
+ viewModel.state.value?.let {
97
+ portal = it
120
98
}
121
99
load(savedInstanceState)
122
100
}
0 commit comments