@@ -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
@@ -26,10 +27,7 @@ import java.math.BigDecimal
26
27
*/
27
28
class RoktKit : KitIntegration (), CommerceListener, IdentityListener, RoktListener, Rokt.RoktCallback {
28
29
private var applicationContext: Context ? = null
29
- private var onUnloadCallback: Runnable ? = null
30
- private var onLoadCallback: Runnable ? = null
31
- private var onShouldHideLoadingIndicatorCallback: Runnable ? = null
32
- private var onShouldShowLoadingIndicatorCallback: Runnable ? = null
30
+ private var mpEventCallback: MParticle .MpEventCallback ? = null
33
31
override fun getName (): String = NAME
34
32
35
33
override fun getInstance (): RoktKit = this
@@ -123,11 +121,8 @@ class RoktKit : KitIntegration(), CommerceListener, IdentityListener, RoktListen
123
121
override fun execute (
124
122
viewName : String ,
125
123
attributes : Map <String , String >? ,
126
- onUnload : Runnable ? ,
127
- onLoad : Runnable ? ,
128
- onShouldHideLoadingIndicator : Runnable ? ,
129
- onShouldShowLoadingIndicator : Runnable ? ,
130
- placeHolders : MutableMap <String , WeakReference <com.mparticle.rokt.RoktEmbeddedView >>? ,
124
+ mpEventCallback : MParticle .MpEventCallback ,
125
+ placeHolders : MutableMap <String , WeakReference <RoktEmbeddedView >>? ,
131
126
fontTypefaces : MutableMap <String , WeakReference <Typeface >>? ,
132
127
filterUser : FilteredMParticleUser ?
133
128
) {
@@ -138,10 +133,7 @@ class RoktKit : KitIntegration(), CommerceListener, IdentityListener, RoktListen
138
133
entry.value.get()?.addView(widget)
139
134
entry.key to WeakReference (widget)
140
135
}?.toMap()
141
- onUnloadCallback = onUnload
142
- onLoadCallback = onLoad
143
- onShouldHideLoadingIndicatorCallback = onShouldHideLoadingIndicator
144
- onShouldShowLoadingIndicatorCallback = onShouldShowLoadingIndicator
136
+ this .mpEventCallback = mpEventCallback
145
137
val finalAttributes: HashMap <String , String > = HashMap <String , String >()
146
138
filterUser?.userAttributes?.let { userAttrs ->
147
139
for ((key, value) in userAttrs) {
@@ -187,19 +179,30 @@ class RoktKit : KitIntegration(), CommerceListener, IdentityListener, RoktListen
187
179
}
188
180
189
181
override fun onLoad () : Unit {
190
- onLoadCallback?. run ()
182
+ mpEventCallback?.onLoad ()
191
183
}
192
184
193
185
override fun onShouldHideLoadingIndicator () : Unit {
194
- onShouldHideLoadingIndicatorCallback?. run ()
186
+ mpEventCallback?.onShouldHideLoadingIndicator ()
195
187
}
196
188
197
189
override fun onShouldShowLoadingIndicator () : Unit {
198
- onShouldShowLoadingIndicatorCallback?. run ()
190
+ mpEventCallback?.onShouldShowLoadingIndicator ()
199
191
}
200
192
201
193
override fun onUnload (reason : Rokt .UnloadReasons ) : Unit {
202
- onUnloadCallback?.run ()
194
+ mpEventCallback?.onUnload(
195
+ when (reason) {
196
+ Rokt .UnloadReasons .NO_OFFERS -> MParticle .UnloadReasons .NO_OFFERS
197
+ Rokt .UnloadReasons .FINISHED -> MParticle .UnloadReasons .FINISHED
198
+ Rokt .UnloadReasons .TIMEOUT -> MParticle .UnloadReasons .TIMEOUT
199
+ Rokt .UnloadReasons .NETWORK_ERROR -> MParticle .UnloadReasons .NETWORK_ERROR
200
+ Rokt .UnloadReasons .NO_WIDGET -> MParticle .UnloadReasons .NO_WIDGET
201
+ Rokt .UnloadReasons .INIT_FAILED -> MParticle .UnloadReasons .INIT_FAILED
202
+ Rokt .UnloadReasons .UNKNOWN_PLACEHOLDER -> MParticle .UnloadReasons .UNKNOWN_PLACEHOLDER
203
+ Rokt .UnloadReasons .UNKNOWN -> MParticle .UnloadReasons .UNKNOWN
204
+ }
205
+ )
203
206
}
204
207
}
205
208
0 commit comments