@@ -118,6 +118,7 @@ class RoktKit : KitIntegration(), CommerceListener, IdentityListener, RoktListen
118
118
For more details, visit the official documentation:
119
119
https://docs.rokt.com/developers/integration-guides/android/how-to/adding-a-placement/
120
120
*/
121
+ @Suppress(" UNCHECKED_CAST" , " CAST_NEVER_SUCCEEDS" )
121
122
override fun execute (
122
123
viewName : String ,
123
124
attributes : Map <String , String >? ,
@@ -131,17 +132,17 @@ class RoktKit : KitIntegration(), CommerceListener, IdentityListener, RoktListen
131
132
) {
132
133
// Converting the placeholders to a Map<String, WeakReference<Widget>> by filtering and casting each entry
133
134
val placeholders: Map <String , WeakReference <Widget >>? = placeHolders?.mapNotNull { entry ->
134
- (entry.value as ? WeakReference < Widget >)?. let {
135
- entry.key to it
136
- }
135
+ val weakRef = entry.value
136
+ val widget = weakRef.get() as ? Widget // Safe cast to Widget
137
+ widget?. let { entry.key to weakRef as WeakReference < Widget > } // Only include if it's a Widget
137
138
}?.toMap()
138
139
onUnloadCallback = onUnload
139
140
onLoadCallback = onLoad
140
141
onShouldHideLoadingIndicatorCallback = onShouldHideLoadingIndicator
141
142
onShouldShowLoadingIndicatorCallback = onShouldShowLoadingIndicator
142
143
val finalAttributes: HashMap <String , String > = HashMap <String , String >()
143
- filterUser?.userAttributes?.let { attributes ->
144
- for ((key, value) in attributes ) {
144
+ filterUser?.userAttributes?.let { userAttrs ->
145
+ for ((key, value) in userAttrs ) {
145
146
finalAttributes[key] = value.toString()
146
147
}
147
148
}
@@ -183,19 +184,19 @@ class RoktKit : KitIntegration(), CommerceListener, IdentityListener, RoktListen
183
184
const val NO_APP_VERSION_FOUND = " No App version found, can't initialize kit."
184
185
}
185
186
186
- override fun onLoad () {
187
+ override fun onLoad () : Unit {
187
188
onLoadCallback?.run ()
188
189
}
189
190
190
- override fun onShouldHideLoadingIndicator () {
191
+ override fun onShouldHideLoadingIndicator () : Unit {
191
192
onShouldHideLoadingIndicatorCallback?.run ()
192
193
}
193
194
194
- override fun onShouldShowLoadingIndicator () {
195
+ override fun onShouldShowLoadingIndicator () : Unit {
195
196
onShouldShowLoadingIndicatorCallback?.run ()
196
197
}
197
198
198
- override fun onUnload (reason : Rokt .UnloadReasons ) {
199
+ override fun onUnload (reason : Rokt .UnloadReasons ) : Unit {
199
200
onUnloadCallback?.run ()
200
201
}
201
202
}
0 commit comments