Sub Class_Globals
Private StartAppSDK As JavaObject
Private StartAppAd As JavaObject
Private ctxt As JavaObject
Public isReady As Boolean = False
Private AdListenerInterstitial As Object
Private AdDisplayListener As Object
Private EventGeneral As String
End Sub
Public Sub Initialize(EventName As String, AppKey As String, testMode As Boolean)
EventGeneral = EventName
If Not(ctxt.IsInitialized) Then ctxt.InitializeContext
If StartAppSDK.IsInitialized Then Return
'INITIALIZE SDK
StartAppSDK.InitializeStatic("com.startapp.sdk.adsbase.StartAppSDK")
StartAppSDK.RunMethod("init", Array(ctxt,AppKey,True))
StartAppSDK.RunMethod("setTestAdsEnabled", Array(testMode))
'AD LISTENER
StartAppAd.InitializeNewInstance("com.startapp.sdk.adsbase.StartAppAd", Array(ctxt))
AdListenerInterstitial = StartAppAd.CreateEventFromUI("com.startapp.sdk.adsbase.adlisteners.AdEventListener", "AdListenerInterstitial", Null)
AdDisplayListener = StartAppAd.CreateEventFromUI("com.startapp.sdk.adsbase.adlisteners.AdDisplayListener", "AdDisplayListener", Null)
End Sub
Private Sub AdListenerIntersticial_Event (MethodName As String, Args() As Object) As Object 'EVENTOS DO BANNER
Select MethodName
Case "onReceiveAd"
If SubExists(ctxt, EventGeneral) Then CallSub2(ctxt,EventGeneral,"onReceiveAd")
isReady = True
Case "onFailedToReceiveAd"
If SubExists(ctxt, EventGeneral) Then CallSub2(ctxt,EventGeneral,"FailedToReceiveAd")
isReady = False
End Select
Return Null
End Sub
Private Sub AdDisplayListener_Event (MethodName As String, Args() As Object) As Object
Select MethodName
Case "adHidden"
If SubExists(ctxt, EventGeneral) Then CallSub2(ctxt,EventGeneral,"adHidden")
Case "adDisplayed"
If SubExists(ctxt, EventGeneral) Then CallSub2(ctxt,EventGeneral,"adDisplayed")
Case "adClicked"
If SubExists(ctxt, EventGeneral) Then CallSub2(ctxt,EventGeneral,"adClicked")
Case "adNotDisplayed"
If SubExists(ctxt, EventGeneral) Then CallSub2(ctxt,EventGeneral,"adNotDisplayed")
End Select
Return Null
End Sub
Public Sub LoadAd
If StartAppAd.IsInitialized Then StartAppAd.RunMethod("loadAd", Array(AdListenerInterstitial))
End Sub
Public Sub showAd
If StartAppAd.IsInitialized And isReady Then StartAppAd.RunMethod("showAd", Array(AdDisplayListener))
End Sub