-
Notifications
You must be signed in to change notification settings - Fork 1
Album
The Album Module is a comprehensive solution for managing photo albums in the application. It provides functionality for creating, viewing, and managing albums, with support for different album types (custom, time-based, and location-based).
- Album creation and management
- Multiple album types (Custom, Time, Location)
- Album cover management
- Photo organization
- Album deletion
- Media scanning and synchronization
The module follows the MVVM (Model-View-ViewModel) architecture pattern:
- View Layer: AlbumFragment, PhotoinAlbumFragment
- ViewModel Layer: AlbumViewModel, PhotoinAlbumViewModel
- Model Layer: AlbumDao, FileRepository
- Adapter Layer: AlbumAdapter, PhotoinAlbumAdapter
AlbumFragment
serves as the main UI component for displaying and managing albums. It implements a hierarchical view of albums categorized by type.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
Initializes the fragment's UI components and sets up the album display.
Implementation Details:
- Initializes section views (custom, time, location)
- Sets up RecyclerViews with GridLayoutManager
- Configures adapters for each section
- Sets up click listeners and observers
private void toggleManageMode()
Toggles the album management mode, enabling/disabling album deletion.
Implementation Details:
- Updates all adapters' management mode
- Shows/hides delete icons
- Maintains consistent state across sections
private void toggleSection(RecyclerView recyclerView, ImageView arrow)
Handles section expansion/collapse.
Parameters:
-
recyclerView
: The section's RecyclerView -
arrow
: The section's arrow indicator
AlbumViewModel
manages album data and operations, handling the business logic for album management.
private MutableLiveData<List<Album>> albumList
private MutableLiveData<DeleteEvent> deleteEvent
private MutableLiveData<String> event
public void loadAlbums()
Loads the user's albums from the database.
Implementation Details:
- Retrieves albums from AlbumDao
- Categorizes albums by type
- Updates LiveData with results
public void addAlbum(String name, int userId, boolean isAutoGenerated,
boolean isCollaborative, String visibility)
Creates a new album.
Parameters:
-
name
: Album name -
userId
: User identifier -
isAutoGenerated
: Whether the album is auto-generated -
isCollaborative
: Whether the album is collaborative -
visibility
: Album visibility setting
public void deleteAlbum(int albumId, String name)
Deletes an album and its contents.
Parameters:
-
albumId
: Album identifier -
name
: Album name
AlbumAdapter
manages the display of album items in RecyclerViews.
- Album cover display
- Album name display
- Delete functionality
- Management mode support
@Override
public void onBindViewHolder(AlbumViewHolder holder, int position)
Binds album data to view holder.
Implementation Details:
- Sets album name
- Loads album cover using Glide
- Handles click events
- Manages delete icon visibility
public void setManageMode(boolean isManageMode)
Toggles management mode.
Parameters:
-
isManageMode
: Whether to enable management mode
Manages the display of photos within an album.
Handles photo data and operations within an album.
Manages the display of photos in the album view.
-
Custom Albums
- User-created albums
- Full management capabilities
- Custom covers
-
Time-based Albums
- Auto-generated by date
- Year and month organization
- Automatic photo categorization
-
Location-based Albums
- Auto-generated by location
- Geographic organization
- Location-based photo grouping
- Creation
- Deletion
- Cover management
- Photo organization
- Visibility settings
- Automatic media scanning
- Cover image management
- Photo synchronization
- Efficient image loading
-
Album Creation
User Input → AlbumViewModel → AlbumDao → FileRepository → UI Update
-
Album Loading
AlbumViewModel → AlbumDao → LiveData → UI Update
-
Photo Management
User Action → PhotoinAlbumViewModel → FileRepository → UI Update
private boolean checkPermissions()
- Checks for required permissions
- Handles different Android versions
- Manages storage access
fileRepository.triggerMediaScanForAlbum(album.name, callback)
- Asynchronous media scanning
- Callback-based updates
- Efficient resource management