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

Improve preference activity startup time #1563

Merged
merged 2 commits into from
Sep 30, 2019

Conversation

maniac103
Copy link
Contributor

Creating the shared prefs instance is an operation that isn't trivial
(takes ~50ms on a OnePlus 6), so avoid doing it over and over again.

Creating the shared prefs instance is an operation that isn't trivial
(takes ~50ms on a OnePlus 6), so avoid doing it over and over again.

Signed-off-by: Danny Baumann <dannybaumann@web.de>
As we do that update in onStart(), there's no need to additionally do it
in onCreatePreferences().

Signed-off-by: Danny Baumann <dannybaumann@web.de>
@maniac103 maniac103 changed the title Create encrypted shared prefs only once. Improve preference activity startup time Sep 30, 2019
@maniac103
Copy link
Contributor Author

I widened the scope to include other performance enhancement fixes for the pref activity.

@maniac103 maniac103 mentioned this pull request Sep 30, 2019
2 tasks
@mueller-ma
Copy link
Member

Creating the shared prefs instance is an operation that isn't trivial

Same applies to Context.getPrefs(), right?

@maniac103
Copy link
Contributor Author

maniac103 commented Sep 30, 2019

Same applies to Context.getPrefs(), right?

No, as the result of Context.getSharedPreferences is cached [1] and `PreferenceManager.getDefaultSharedPreferences is just a wrapper around that [2].

[1] https://android.googlesource.com/platform/frameworks/base/+/refs/heads/android10-release/core/java/android/app/ContextImpl.java#451
[2] https://android.googlesource.com/platform/frameworks/support/+/refs/heads/androidx-master-dev/preference/preference/src/main/java/androidx/preference/PreferenceManager.java#119

Copy link
Member

@mueller-ma mueller-ma left a comment

Choose a reason for hiding this comment

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

LGTM!

@mueller-ma mueller-ma merged commit a1289e1 into openhab:master Sep 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants