Skip to main content

Group components - Android

Create a component group

val group1 =
UXComponents.createGroup(
context = this,
arrayListOf(binding.password, binding.passwordConfirm)
)

Add a component to a group

e.g., you want to add password component and card number component, you can accomplish this by adding:

group1.addComponents(arrayListOf(binding.passwordConfirm, binding.password))

Remove a component from a group

group1.removeComponents(arrayListOf(binding.passwordConfirm))

Check for data match

Data matching is about validating a user input

if (group1.match()) {
Toast.makeText(this, "Password matched", Toast.LENGTH_SHORT).show()
}

Create token out of grouped components

group1.createToken(
fieldKeys = arrayListOf("passKey0", "passKey1","passKey2"),
callBack =
object : WeavrResult<Map<String, String?>, ErrorResponse> { override fun onSuccess(result: Map<String, String?>?) {
JSONObject(result).toString()
Log.d(Tag, "onSuccess: $result")
val firstComponentValue = result?.get("passKey0")
Log.d(Tag, "onSuccess: $firstComponentValue")
}
override fun onFailure(error: ErrorResponse) {
Log.d(Tag, "onFailure: $error")
}
})