@@ -6,6 +6,7 @@ import android.content.pm.PackageInfo
6
6
import android.content.pm.PackageManager
7
7
import android.graphics.Typeface
8
8
import android.os.Build
9
+ import com.mparticle.MParticle
9
10
import com.mparticle.commerce.CommerceEvent
10
11
import com.mparticle.identity.MParticleUser
11
12
import com.mparticle.internal.Logger
@@ -25,10 +26,7 @@ import java.math.BigDecimal
25
26
*/
26
27
class RoktKit : KitIntegration (), CommerceListener, IdentityListener, RoktListener, Rokt.RoktCallback {
27
28
private var applicationContext: Context ? = null
28
- private var onUnloadCallback: Runnable ? = null
29
- private var onLoadCallback: Runnable ? = null
30
- private var onShouldHideLoadingIndicatorCallback: Runnable ? = null
31
- private var onShouldShowLoadingIndicatorCallback: Runnable ? = null
29
+ private var mpRoktEventCallback: MParticle .MpRoktEventCallback ? = null
32
30
override fun getName (): String = NAME
33
31
34
32
override fun getInstance (): RoktKit = this
@@ -122,11 +120,8 @@ class RoktKit : KitIntegration(), CommerceListener, IdentityListener, RoktListen
122
120
override fun execute (
123
121
viewName : String ,
124
122
attributes : Map <String , String >? ,
125
- onUnload : Runnable ? ,
126
- onLoad : Runnable ? ,
127
- onShouldHideLoadingIndicator : Runnable ? ,
128
- onShouldShowLoadingIndicator : Runnable ? ,
129
- placeHolders : MutableMap <String , WeakReference <com.mparticle.rokt.RoktEmbeddedView >>? ,
123
+ mpRoktEventCallback : MParticle .MpRoktEventCallback ,
124
+ placeHolders : MutableMap <String , WeakReference <RoktEmbeddedView >>? ,
130
125
fontTypefaces : MutableMap <String , WeakReference <Typeface >>? ,
131
126
filterUser : FilteredMParticleUser ?
132
127
) {
@@ -136,10 +131,7 @@ class RoktKit : KitIntegration(), CommerceListener, IdentityListener, RoktListen
136
131
val widget = weakRef.get() as ? Widget // Safe cast to Widget
137
132
widget?.let { entry.key to weakRef as WeakReference <Widget > } // Only include if it's a Widget
138
133
}?.toMap()
139
- onUnloadCallback = onUnload
140
- onLoadCallback = onLoad
141
- onShouldHideLoadingIndicatorCallback = onShouldHideLoadingIndicator
142
- onShouldShowLoadingIndicatorCallback = onShouldShowLoadingIndicator
134
+ this .mpRoktEventCallback = mpRoktEventCallback
143
135
val finalAttributes: HashMap <String , String > = HashMap <String , String >()
144
136
filterUser?.userAttributes?.let { userAttrs ->
145
137
for ((key, value) in userAttrs) {
@@ -185,19 +177,30 @@ class RoktKit : KitIntegration(), CommerceListener, IdentityListener, RoktListen
185
177
}
186
178
187
179
override fun onLoad () : Unit {
188
- onLoadCallback?. run ()
180
+ mpRoktEventCallback?.onLoad ()
189
181
}
190
182
191
183
override fun onShouldHideLoadingIndicator () : Unit {
192
- onShouldHideLoadingIndicatorCallback?. run ()
184
+ mpRoktEventCallback?.onShouldHideLoadingIndicator ()
193
185
}
194
186
195
187
override fun onShouldShowLoadingIndicator () : Unit {
196
- onShouldShowLoadingIndicatorCallback?. run ()
188
+ mpRoktEventCallback?.onShouldShowLoadingIndicator ()
197
189
}
198
190
199
191
override fun onUnload (reason : Rokt .UnloadReasons ) : Unit {
200
- onUnloadCallback?.run ()
192
+ mpRoktEventCallback?.onUnload(
193
+ when (reason) {
194
+ Rokt .UnloadReasons .NO_OFFERS -> MParticle .UnloadReasons .NO_OFFERS
195
+ Rokt .UnloadReasons .FINISHED -> MParticle .UnloadReasons .FINISHED
196
+ Rokt .UnloadReasons .TIMEOUT -> MParticle .UnloadReasons .TIMEOUT
197
+ Rokt .UnloadReasons .NETWORK_ERROR -> MParticle .UnloadReasons .NETWORK_ERROR
198
+ Rokt .UnloadReasons .NO_WIDGET -> MParticle .UnloadReasons .NO_WIDGET
199
+ Rokt .UnloadReasons .INIT_FAILED -> MParticle .UnloadReasons .INIT_FAILED
200
+ Rokt .UnloadReasons .UNKNOWN_PLACEHOLDER -> MParticle .UnloadReasons .UNKNOWN_PLACEHOLDER
201
+ Rokt .UnloadReasons .UNKNOWN -> MParticle .UnloadReasons .UNKNOWN
202
+ }
203
+ )
201
204
}
202
205
}
203
206
0 commit comments