Merged
Conversation
…e selection - Prevent potential null pointer exceptions by using safe calls on `sessionManager` when ending a current session or retrieving session data.
- **Library & Paging**:
- Migrates `LibrarySongsTab` to use `LazyPagingItems<Song>` for efficient memory usage and smoother scrolling in large libraries.
- Introduces `LibraryViewModel` and `LibraryStateHolder` to manage the Paging flow and handle library loading states.
- Implements Room-backed pagination in `MusicDao` and `MediaStoreSongRepository` with support for multiple sort orders (A-Z, Artist, Album, Date Added, Duration).
- Synchronizes selection mode and playback queue logic with Paging snapshots.
- **Data Layer Improvements**:
- Updates `MusicRepository` and `SongRepository` interfaces to support paginated song fetching with sort options.
- Refactors `getSongsForAlbum`, `getArtistsForSong`, and `getSongsForArtist` to fetch data directly from `MusicDao` on `Dispatchers.IO` for better performance.
- Adjusts `MediaStoreSongRepository` to include a minimum duration filter (10s) and handles directory exclusion filtering directly via Room.
- **UI Refinements**:
- Reorganizes `LibrarySongsTab` code for better maintainability and integrates it into `LibraryScreen`.
- Updates `LibraryScreen` to use the new `LibraryViewModel` for data fetching.
- Enhances `EnhancedSongListItem` usage within the paginated list to support loading placeholders and selection states.
- **Dependency Injection**:
- Updates `AppModule` to reflect changes in `SongRepository` and `LyricsRepositoryImpl` dependencies.
- Remove `allSongs`, `albums`, `artists`, and `songCount` from `PlayerUiState` to reduce UI state size and unnecessary updates. - Expose `albumsFlow` and `artistsFlow` directly from `PlayerViewModel` using `LibraryStateHolder` flows. - Update `LibraryScreen` and `GenreDetailScreen` to collect library data from these standalone flows instead of the monolithic UI state. - Optimize `LibraryScreen` by removing redundant state transformations and `remember` blocks for library categories. - Update shuffle logic in `PlayerViewModel` to access library data via `LibraryStateHolder`.
- **LibrarySongsTab**: Added `sortOption` parameter and a `LaunchedEffect` to reset scroll position to the top when the sorting criteria changes. - **LibraryAlbumsTab**: Implemented `LaunchedEffect` to scroll both list and grid views to the top upon changing the album sort option. - **LibraryArtistsTab**: Added logic to reset scroll position to the top when the artist sort option is updated. - **LibraryScreen**: Updated `LibrarySongsTab` call site to provide `currentSongSortOption` from `playerUiState`.
- **Refactoring**: Move complex folder hierarchy building logic from `MusicRepositoryImpl` to a dedicated `FolderTreeBuilder` class to improve maintainability and testability.
- **Optimization**: Clean up path normalization and parent-path resolution by using string manipulation instead of repeated `File` object instantiation.
- **Dependency Injection**:
- Provide `FolderTreeBuilder` as a `@Singleton` in `AppModule`.
- Update `MusicRepositoryImpl` to receive `FolderTreeBuilder` via constructor injection.
- **Data & Logic**:
- Update `FolderTreeBuilder` to handle directory rule resolution and song filtering.
- Maintain existing logic for internal and SD card storage root detection.
- Ensure songs are sorted by track number and title within the generated tree.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
General optimizations with paging 3 and media store