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

Improved and Updated Code #19

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Improved and Updated Code #19

wants to merge 2 commits into from

Conversation

DatL4g
Copy link

@DatL4g DatL4g commented Apr 14, 2022

🚀 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 Pass layout in activity constructor #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

  • Bug fix (non-breaking change which fixes an issue)
    Fixed memory leaks

  • New feature (non-breaking change which adds functionality)
    Pass layout in Fragment constructor and overload functions for Java

  • 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

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

replaced liveData with flow
replaced some get methods with final variables and getter
layout can be passed in fragment constructor
@sonarcloud
Copy link

sonarcloud bot commented Apr 14, 2022

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

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.

Pass layout in activity constructor
1 participant