Maui
Maui copied to clipboard
Readonly Struct Record instead of ValueTuples
- Bug fix
Description of Change
This commit introduces significant improvements to the MauiMediaElement
class for Android, focusing on the management of the current activity and its window. A new record struct, CurrentPlatformActivity
, has been added to encapsulate the current Activity
and its Window
, streamlining the handling process and enhancing code readability and maintainability. Changes include:
- The constructor of
MauiMediaElement
now checks for nullPlatform.CurrentActivity
or window, throwing anInvalidOperationException
if either is null, ensuring the element's proper context for operation. - The
CurrentPlatformActivity
record struct replaces the need for the previously used static methodVerifyAndRetrieveCurrentWindowResources
, removing redundancy. - Full-screen functionality and system bars visibility adjustments now directly utilize the
currentPlatformActivity
instance for accessing the current window, simplifying the implementation and improving code clarity.
These modifications collectively enhance the clarity, efficiency, and error handling of the MauiMediaElement
class on Android.
Linked Issues
- Fixes #1971
PR Checklist
- [x] Has a linked Issue, and the Issue has been
approved
(bug) orChampioned
(feature/proposal) - [ ] Has tests (if omitted, state reason in description)
- [ ] Has samples (if omitted, state reason in description)
- [x] Rebased on top of
main
at time of PR - [x] Changes adhere to coding standard
- [ ] Documentation created or updated: https://github.com/MicrosoftDocs/CommunityToolkit/pulls
Additional information
@pictos requested replacing ValueTuples
with readonly struct record