This repository has been archived by the owner on Dec 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor code (no new functionality added)
- Extract ThreadSafeCachedValueHolder.kt as a separate parameterized and re-usable class that can hold any "value" object, not just Settings. - Create a ThreadSafeSettingsHolder class that customizes the generic class above for use w/ Settings and Android persistence by providing a loader lambda. - Cleaned up the MainActivity.kt so that it can now correctly respond to settings change events fired by EventBus. - Also in MainActivity.kt, clean up the spinner selection code. Currently, onCreate() and onSettingsChangedEvent() both end up restoring the saved spinner position. This used to result in needless calls to persistence to save and fire this event twice! - This happens due to the behavior of the Android spinner to fire its onItemSelected() method for programmatic as well as user initiated changes to its selection! - There are other ways of handling this which I didn't use: https://stackoverflow.com/a/25070707/2085356
- Loading branch information
1 parent
ec8004a
commit 915541a
Showing
5 changed files
with
148 additions
and
100 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.