Android-Animated-Theme-Manager icon indicating copy to clipboard operation
Android-Animated-Theme-Manager copied to clipboard

Improved and Updated Code

Open DatL4g opened this issue 2 years ago โ€ข 1 comments

๐Ÿš€ 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.

DatL4g avatar Apr 14 '22 18:04 DatL4g

Kudos, SonarCloud Quality Gate passed!ย  ย  Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

sonarcloud[bot] avatar Apr 14 '22 18:04 sonarcloud[bot]