@@ -6,12 +6,14 @@ 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
1213import com.mparticle.kits.KitIntegration.CommerceListener
1314import com.mparticle.kits.KitIntegration.IdentityListener
1415import com.mparticle.kits.KitIntegration.RoktListener
16+ import com.mparticle.rokt.RoktEmbeddedView
1517import com.rokt.roktsdk.Rokt
1618import com.rokt.roktsdk.Widget
1719import java.lang.ref.WeakReference
@@ -25,10 +27,7 @@ import java.math.BigDecimal
2527 */
2628class RoktKit : KitIntegration (), CommerceListener, IdentityListener, RoktListener, Rokt.RoktCallback {
2729 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
3231 override fun getName (): String = NAME
3332
3433 override fun getInstance (): RoktKit = this
@@ -122,11 +121,8 @@ class RoktKit : KitIntegration(), CommerceListener, IdentityListener, RoktListen
122121 override fun execute (
123122 viewName : String ,
124123 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 >>? ,
130126 fontTypefaces : MutableMap <String , WeakReference <Typeface >>? ,
131127 filterUser : FilteredMParticleUser ?
132128 ) {
@@ -136,10 +132,7 @@ class RoktKit : KitIntegration(), CommerceListener, IdentityListener, RoktListen
136132 val widget = weakRef.get() as ? Widget // Safe cast to Widget
137133 widget?.let { entry.key to weakRef as WeakReference <Widget > } // Only include if it's a Widget
138134 }?.toMap()
139- onUnloadCallback = onUnload
140- onLoadCallback = onLoad
141- onShouldHideLoadingIndicatorCallback = onShouldHideLoadingIndicator
142- onShouldShowLoadingIndicatorCallback = onShouldShowLoadingIndicator
135+ this .mpRoktEventCallback = mpRoktEventCallback
143136 val finalAttributes: HashMap <String , String > = HashMap <String , String >()
144137 filterUser?.userAttributes?.let { userAttrs ->
145138 for ((key, value) in userAttrs) {
@@ -185,19 +178,30 @@ class RoktKit : KitIntegration(), CommerceListener, IdentityListener, RoktListen
185178 }
186179
187180 override fun onLoad () : Unit {
188- onLoadCallback?. run ()
181+ mpRoktEventCallback?.onLoad ()
189182 }
190183
191184 override fun onShouldHideLoadingIndicator () : Unit {
192- onShouldHideLoadingIndicatorCallback?. run ()
185+ mpRoktEventCallback?.onShouldHideLoadingIndicator ()
193186 }
194187
195188 override fun onShouldShowLoadingIndicator () : Unit {
196- onShouldShowLoadingIndicatorCallback?. run ()
189+ mpRoktEventCallback?.onShouldShowLoadingIndicator ()
197190 }
198191
199192 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+ )
201205 }
202206}
203207
0 commit comments