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