Created
November 16, 2021 14:21
-
-
Save G00fY2/b00d30a39f6c9888b6127817c820ecd8 to your computer and use it in GitHub Desktop.
UsabillaController example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context | |
import com.usabilla.sdk.ubform.Usabilla | |
import com.usabilla.sdk.ubform.UsabillaReadyCallback | |
import com.example.app.BuildConfig | |
import javax.inject.Inject | |
class UsabillaControllerImpl @Inject constructor() : UsabillaController, UsabillaReadyCallback { | |
@Inject | |
lateinit var context: Context | |
private val queue = mutableListOf<String>() | |
private var initialized = false | |
override fun initialize() { | |
Usabilla.initialize(context, BuildConfig.USABILLA_APP_ID, null, this) | |
} | |
override fun onUsabillaInitialized() { | |
initialized = true | |
queue.forEach { Usabilla.sendEvent(context, it) } | |
queue.clear() | |
} | |
override fun sendEvent(event: String) { | |
if (initialized) { | |
Usabilla.sendEvent(context, event) | |
} else { | |
queue.add(event) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment