Android-Animated-Theme-Manager
Android-Animated-Theme-Manager copied to clipboard
Improved and Updated Code
๐ Description
This PR contains multiple changes.
- ThemeManager class has been changed to an object (as it has been used in an object like way before).
- Previous ThemeManager had a potential memory leak of the activity, this has been fixed by wrapping it in a WeakReference.
- ThemeActivity had potential memory leaks of views, this has been fixed.
- Fragments can pass the layout in their constructor which partly fixes #14 (I don't think the same thing is possible for activities)
- LiveData containing the theme has been changed to a StateFlow for more flexibility
- Added
@JvmOverloads
on some functions for better Java compatibility - Replaced some get methods with final variables and getter
๐ Motivation and Context
- Fixes some potential memory leaks.
- Improved flexibility, usage and compatibility
I've made those changes because it was not nice to use with unnecessary get methods and depending on LiveData as it's not flexible enough for my usecase. Additionally I could not pass the layout inside the Fragment constructor what I normally do #14.
๐งช How Has This Been Tested?
I've tested it using an emulator, opend every activity and navigated further (e.g. next activity or next fragment). No crash occurred and it works as expected.
๐ฆ Types of changes
-
[x] Bug fix (non-breaking change which fixes an issue) Fixed memory leaks
-
[x] New feature (non-breaking change which adds functionality) Pass layout in Fragment constructor and overload functions for Java
-
[x] Breaking change (fix or feature that would cause existing functionality to not work as expected) Replaced LiveData with Flow and replaced some methods with variables ThemeManager is an object now what means no
instance
call on it
โ Checklist
- [x] My code follows the code style of this project.
- [x] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
Kudos, SonarCloud Quality Gate passed!ย ย