-
Notifications
You must be signed in to change notification settings - Fork 527
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
Fix #1737: Singleton for exploration to handle input for configuration changes #2514
Fix #1737: Singleton for exploration to handle input for configuration changes #2514
Conversation
… singleton-for-exploration
… singleton-for-exploration
@rt4914 @BenHenning Here I can get the pending answer and can save it after configuration change but how do set it to the |
|
||
import org.oppia.android.app.model.UserAnswer | ||
|
||
object RetriveUserAnswer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a Dagger singleton (see other @Singleton
marked classes in the codebase).
@FareesHussain I suspect that you will need to find a way to pre-populate the views with initial user answers pre-populated. You can determine the need for that at the fragment level (e.g. on configuration change), and you'll need to find a way to incorporate the initial answer as part of the view models that are used to populate answers. Note also that we will need to store a plain text representation of the answer to keep it exactly the same (e.g. if a user enters ' 2 ' then the spaces should be retained on configuration change). This may require additional considerations since the answers do have different types, and 'UserAnswer' cannot correctly capture these sorts of nuances in answers. Also, keep in mind that this was not expect to be an easy issue, and I wouldn't be surprised if many different files need to be changed in order for this functionality to be properly built. |
Will be checking this on Monday. Thanks. |
Will discuss in meeting as per out chat. |
@@ -56,19 +57,24 @@ class FractionInteractionViewModel( | |||
return userAnswerBuilder.build() | |||
} | |||
|
|||
override fun setPendingAnswer(userAnswer: UserAnswer) { | |||
answerText.set(userAnswer.plainAnswer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BenHenning Here I'm unable to update the View using this method is there any other way to do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you be specific on what isn’t working? It’s sometimes hard to tell from just the code. The more specific you can be the better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I'm able to send the userAnswer (pending answer after configuration change) to the FractionInteractionViewModel but i'm unable to update it using the ObservableField for answerText
(updated it string -> ObservableField to update the Input through viewmodel). Here I'm able to get the value but I'm unable to update the FractionInteractionView.
Is the implementation correct
Is there any other way to update the FractionInteractionView using the ViewModel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. Just to check: did you confirm:
- setPendingAnswer is being called here
- setPendingAnswer is being passed new data
- The current value of answerText when setPendingAnswer is called isn't what you expect (e.g. empty)
If all are true, I'm not exactly sure what's wrong. observable fields should work out of the box, but you could try calling notifyChange
on the view model (per https://github.com/oppia/oppia-android/blob/develop/app/src/main/java/org/oppia/android/app/viewmodel/ObservableViewModel.kt#L23). FWIW I think you can actually avoid observable field if you use notifyChange, but maybe start with both to reduce the number of things that could be wrong here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked this:
answerText
is already set to the value which is coming from setPendingAnswer
but the FractionInteractionView is not displaying it.
Also, notifyChange()
did not work.
I think the issues is something else because answerText
is showing the correct value its just not visible in screen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. I'm wondering if this is behaving this way because we have a text watcher set. It might be the case that we aren't actually copying over the value to answerText directly from databinding (& instead rely on the text watcher). I won't have time to dig into this right now, but @FareesHussain I suggest searching for whether a text watcher can interfere with databinding.
@BenHenning I tried to use notifyChange by removing the ObservableField for the Is there any other way to update the input value of |
@FareesHussain de-assigning myself for now. Like mentioned earlier, I suspect this is tied to the TextWatcher (e.g. it might be intercepting text changes rather than letting them propagate correctly with databinding) and will require some level of debugging to verify. If it is caused by that, then you may need to manually call setText on the custom view when the observable changes (which may require calling a custom method in the custom view class to setText rather than using the built-in adapter for TextView via the layout file). |
@FareesHussain Is this PR blocked on something? |
… singleton-for-exploration
@FareesHussain any update on this? |
will discuss this in today's meeting |
Un-assigning as I was unable to solve this. |
Hi @FareesHussain, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 3 days, it will be automatically closed so that others can take up the issue. |
Explanation
Fixes #1737
Checklist