Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the UI using the answers in the view model #134

Merged
merged 7 commits into from
Jan 7, 2021

Conversation

jingtang10
Copy link
Collaborator

We had not implemented this because we assumed that it's ok to render the UI without providing an initial value until we implement the initial value to the SDC specification.

However, this already caused issue because the recycler view reuses the questionnaire item views, and if we don't try to set the answer the view might still carry what the user had input for a different question.

@jingtang10
Copy link
Collaborator Author

thanks yigit :) ptal!

Copy link
Collaborator Author

@jingtang10 jingtang10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ptal

@jingtang10 jingtang10 requested a review from yigit January 6, 2021 21:46
)
) {
var singleAnswerOrNull
get() = questionnaireResponseItemComponent.answer.singleOrNull()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if you meant this but singleOrNull returns null if there are more than 1 items:
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/single-or-null.html

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think basically there's something really wrong if we have multiple answers here. I'm happy with this rather lenient method rather than throwing exception or returning first.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be good to add a comment here to specify it is intentional.

)
) {
var singleAnswerOrNull
get() = questionnaireResponseItemComponent.answer.singleOrNull()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

)
) {
var singleAnswerOrNull
get() = questionnaireResponseItemComponent.answer.singleOrNull()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be good to add a comment here to specify it is intentional.

@jingtang10 jingtang10 merged commit f72b516 into master Jan 7, 2021
@jingtang10 jingtang10 deleted the jt/sdc-set-values branch January 7, 2021 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

datacapture : Bug in binding UI element to Questionnaire Item
3 participants