-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
refactor: Automatic Display Answer #9631
Conversation
The method is always called from onCollectionLoaded so we can remove a dependency
Extracts "onCollectionLoadError" to a method to remove duplicated code restoreCollectionPreferences: If an exception occurs, this will be because there is a problem with the collection, or a problem with the data Either way, we want to return to the deck picker
We're going to add functionality here, and this is the first step to making this change easier to reason about. Removes two variables from AbstractFlashcardViewer
Removes 4 variables in AbstractFlashcardViewer
on DisplayCardQuestion, we used to check to see which options to use. But these don't change (mOptUseGeneralTimerSettings is loaded in onCollectionLoaded) So we can remove the code, effectively keeping the class as a constant preferences are loaded onCreate collection is loaded onCollectionLoaded
Move loading the concern into its class
Move the generation logic into its own class This moves the initialisation of the class from onCreate to onCollectionLoaded This seems sensible, and removes the need for double initialization
Removes mTimeoutHandler from AbstractFlashcardViewer This is an incremental (bad) refactoring Now we've removed the handler, we can move most of the internal logic into the AutomaticAnswerSettings class This will let us make more methods private
moves more behavior inside the object Still not too well factored, but getting there
moves more behavior inside the object By default, we start the timer after all media has played If we are reading text, we don't calculate the time it takes. Instead, we wait for the text to complete before we display Q/A Allows us to make settings private
moves more behavior inside the object Allows us to make settings private
Split out settings from the answerer
refactor easy methods out of the reviewer getBackgroundColors getTextColors
Even if a media delay is provided, there should be no auto answer if the times are set to 0s
This should make #9170 a "good first issue" when it's in. |
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 all look fine - I hate to say "while you're in there..." but there's no better case of it with regard to finally put #2609 in and this probably blew apart the existing (dormant) PR
Already got that ready for when this merges |
That's huge! So many people want that |
Purpose / Description
Refactor to remove more code from the CardViewer
Fixes
Pre #2609
How Has This Been Tested?
Unit tested, and it seems to work. I've added follow on commits (not pushed yet) with more functionality, and these work
Checklist
if
statements)