@@ -6,6 +6,7 @@ import android.content.pm.PackageInfo
66import android.content.pm.PackageManager
77import android.graphics.Typeface
88import android.os.Build
9+ import com.mparticle.MParticle
910import com.mparticle.commerce.CommerceEvent
1011import com.mparticle.identity.MParticleUser
1112import com.mparticle.internal.Logger
@@ -25,10 +26,7 @@ import java.math.BigDecimal
2526 */
2627class RoktKit : KitIntegration (), CommerceListener, IdentityListener, RoktListener, Rokt.RoktCallback {
2728 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
3230 override fun getName (): String = NAME
3331
3432 override fun getInstance (): RoktKit = this
@@ -122,11 +120,8 @@ class RoktKit : KitIntegration(), CommerceListener, IdentityListener, RoktListen
122120 override fun execute (
123121 viewName : String ,
124122 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 >>? ,
130125 fontTypefaces : MutableMap <String , WeakReference <Typeface >>? ,
131126 filterUser : FilteredMParticleUser ?
132127 ) {
@@ -136,10 +131,7 @@ class RoktKit : KitIntegration(), CommerceListener, IdentityListener, RoktListen
136131 val widget = weakRef.get() as ? Widget // Safe cast to Widget
137132 widget?.let { entry.key to weakRef as WeakReference <Widget > } // Only include if it's a Widget
138133 }?.toMap()
139- onUnloadCallback = onUnload
140- onLoadCallback = onLoad
141- onShouldHideLoadingIndicatorCallback = onShouldHideLoadingIndicator
142- onShouldShowLoadingIndicatorCallback = onShouldShowLoadingIndicator
134+ this .mpRoktEventCallback = mpRoktEventCallback
143135 val finalAttributes: HashMap <String , String > = HashMap <String , String >()
144136 filterUser?.userAttributes?.let { userAttrs ->
145137 for ((key, value) in userAttrs) {
@@ -185,19 +177,30 @@ class RoktKit : KitIntegration(), CommerceListener, IdentityListener, RoktListen
185177 }
186178
187179 override fun onLoad () : Unit {
188- onLoadCallback?. run ()
180+ mpRoktEventCallback?.onLoad ()
189181 }
190182
191183 override fun onShouldHideLoadingIndicator () : Unit {
192- onShouldHideLoadingIndicatorCallback?. run ()
184+ mpRoktEventCallback?.onShouldHideLoadingIndicator ()
193185 }
194186
195187 override fun onShouldShowLoadingIndicator () : Unit {
196- onShouldShowLoadingIndicatorCallback?. run ()
188+ mpRoktEventCallback?.onShouldShowLoadingIndicator ()
197189 }
198190
199191 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+ )
201204 }
202205}
203206
0 commit comments