Skip to content

Commit 4790330

Browse files
committed
removed custom viewmodel ability for now
1 parent f7d8953 commit 4790330

File tree

3 files changed

+5
-27
lines changed

3 files changed

+5
-27
lines changed

IonicPortals/src/main/kotlin/io/ionic/portals/PortalFragment.kt

+3-25
Original file line numberDiff line numberDiff line change
@@ -52,41 +52,25 @@ open class PortalFragment : Fragment {
5252
private var initialContext: Any? = null
5353

5454
private val viewModel: PortalViewModel by viewModels()
55-
private var providedViewModel: PortalViewModel? = null
5655

5756
constructor()
5857

5958
constructor(portal: Portal?) {
6059
this.portal = portal
6160
}
6261

63-
constructor(portal: Portal?, viewModel: PortalViewModel) {
64-
this.portal = portal
65-
this.providedViewModel = viewModel
66-
}
67-
6862
constructor(portal: Portal?, onBridgeAvailable: ((bridge: Bridge) -> Unit)?) {
6963
this.portal = portal
7064
this.onBridgeAvailable = onBridgeAvailable
7165
}
7266

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-
7967
/**
8068
* Extends the Android Fragment `onCreate` lifecycle event.
8169
*/
8270
override fun onCreate(savedInstanceState: Bundle?) {
8371
super.onCreate(savedInstanceState)
8472
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
9074
}
9175
}
9276

@@ -109,14 +93,8 @@ open class PortalFragment : Fragment {
10993
*/
11094
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
11195
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
12098
}
12199
load(savedInstanceState)
122100
}

TestApp/src/main/AndroidManifest.xml

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<activity
2121
android:name=".ViewModelActivity"
2222
android:exported="true">
23+
2324
<intent-filter>
2425
<action android:name="android.intent.action.VIEW" />
2526
<category android:name="android.intent.category.DEFAULT" />

TestApp/src/main/java/io/ionic/portals/testapp/ViewModelActivity.kt

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ class ViewModelActivity : AppCompatActivity() {
2121
add(
2222
R.id.fragmentContainerView,
2323
PortalFragment(
24-
portal = PortalBuilder("testportal").create(),
25-
viewModel = viewModel
24+
portal = PortalBuilder("testportal").create()
2625
),
2726
"test"
2827
)

0 commit comments

Comments
 (0)