Anime Explorer is a modern Android app built with Jetpack Compose, MVVM Clean Architecture, and Koin DI, designed to fetch and display top anime series from the API. It features a polished UI with offline support, Room database caching, robust error handling, and seamless YouTube trailer playback, ensuring a smooth user experience even in challenging network conditions. The app gracefully handles legal constraints on images, provides comprehensive state management with StateFlow, and maintains a clean, well-documented codebase for easy maintenance and scalability.
AnimeExplorer.demo.video.mp4
API Integration: Uses Jikan API endpoint https://api.jikan.moe/v4/top/anime
via ApiService.getTopAnime()
UI Implementation: app/src/main/java/com/animeExplorer/ui/screens/animeList/
- AnimeListScreen.kt: Main home screen with LazyColumn displaying anime list
- AnimeCard.kt: Individual anime card component showing all required fields:
- Title: Large, bold text with ellipsis for long titles
- Number of Episodes: Displayed with play icon and proper singular/plural handling
- Rating: MyAnimeList score with star icon and gold color
- Poster Image: High-quality anime poster with fallback to large image URL
Data Flow: AnimeListViewModel
β AnimeRepository
β ApiService
β Jikan API
API Integration: Uses https://api.jikan.moe/v4/anime/{anime_id}
via ApiService.getAnimeDetails()
UI Implementation: app/src/main/java/com/animeExplorer/ui/screens/animeDetails/
- AnimeDetailsScreen.kt: Main detail screen with comprehensive layout
- AnimeDetailsContent.kt: Content component displaying all required fields:
- Video Player:
TrailerPlayer.kt
with YouTube integration using android-youtube-player library - Poster Image Fallback: When no trailer available, shows poster image with overlay text
- Title: Large, prominent title display
- Plot/Synopsis: Full synopsis with proper text formatting and line height
- Genre(s): Horizontal scrollable filter chips with Material 3 design
- Main Cast: Character list with bullet points (top 10 characters)
- Number of Episodes: Displayed with play icon and proper text
- Rating: MyAnimeList score with star icon and gold color
- Video Player:
Navigation: Deep linking with {animeId}
parameter for seamless navigation
Implementation: app/src/main/java/com/animeExplorer/data/local/
- AnimeDatabase.kt: Room database configuration with proper schema
- AnimeEntity.kt: Anime list data entity for local storage
- AnimeDetailsEntity.kt: Detailed anime information entity
- AnimeDao.kt & AnimeDetailsDao.kt: Database access objects for CRUD operations
Features:
- Store fetched anime data locally: Complete anime list and details cached
- Use Room for database operations: Full Room implementation with KSP
- Data syncs when online: Automatic sync mechanism in repository
Implementation: app/src/main/java/com/animeExplorer/data/repository/AnimeRepository.kt
Features:
- App functions without internet: Full offline functionality with cached data
- Sync data with server when online: Automatic background sync with conflict resolution
UI Behavior:
- Loading states show cached data immediately
- Background sync updates content seamlessly
- No network dependency for viewing stored anime
Comprehensive error handling across all layers:
API Error Handling:
- Network timeouts (30 seconds) configured in
NetworkModule.kt
- HTTP error responses handled gracefully in repository
- Graceful fallback to cached data when API fails
Database Error Handling:
- Room operation exceptions caught and handled
- Data corruption protection with proper error states
- Graceful degradation when database operations fail
Network Error Handling:
- Connection state monitoring
- Retry mechanisms with exponential backoff
- Error messages with retry options
UI Error States:
- Loading, success, and error states managed in ViewModels
ErrorContent.kt
component for consistent error display- Retry buttons for failed operations
- Proper error messages in user's language
Clean MVVM Architecture with Koin DI:
MVVM Pattern:
AnimeListViewModel.kt
&AnimeDetailsViewModel.kt
: ViewModels with StateFlowAnimeListUiState
&AnimeDetailsUiState
: UI state management- Reactive data handling with StateFlow
Repository Pattern: AnimeRepository.kt
- Single source of truth for data
Dependency Injection: Koin modules in app/src/main/java/com/animeExplorer/di/
NetworkModule.kt
: Retrofit, OkHttp, API serviceDatabaseModule.kt
: Room database and DAOsRepositoryModule.kt
: Repository implementationsViewModelModule.kt
: ViewModels
Best-in-Class Libraries:
- Retrofit: API calls with OkHttp logging interceptor
- Coil: Modern image loading (alternative to Glide/Picasso)
- Room: Database with KSP for compile-time code generation
- StateFlow: Reactive data handling (alternative to LiveData)
- Navigation Compose: Screen navigation
- Material 3: Modern design system
Legal Constraint Implementation for Anime Images:
Placeholder System:
ic_anime_placeholder.xml
: Fallback image for unavailable anime posters- Graceful degradation when images become unavailable due to legal changes
Error Handling:
AsyncImage
witherror
andplaceholder
parameters inAnimeCard.kt
- Same implementation in
TrailerPlayer.kt
- Layout remains intact with consistent placeholder images
Legal Compliance:
SHOW_ANIME_IMAGES
constant inAppConstants.kt
for easy toggle- When
false
, shows placeholder instead of actual images - No broken UI when images are legally restricted
Edge Cases Handled:
- Null image URLs with fallback to large image URLs
- Missing trailer data with poster image fallback
- Empty character lists with proper UI handling
- Network timeouts and retry logic
- Database corruption recovery
- Long titles with ellipsis truncation
- Missing episode counts with proper null handling
Robustness Features:
- Network Resilience: Automatic retry with exponential backoff
- Offline Support: Full offline functionality with cached data
- Error Management: Comprehensive error states and user feedback
UI/UX Intuitiveness:
- Material 3 design with consistent theming
- Smooth animations and transitions (
FadeInAnimation
,ScaleAnimation
,SlideInAnimation
) - Loading states and progress indicators
- Clear error messages with retry options
- Responsive design for different screen sizes
- Proper content descriptions for accessibility
Code Organization:
- Well-structured package hierarchy
- Clear separation of concerns
- Extensive code documentation with author attribution
- Consistent naming conventions
- Reusable components and utilities
Implementation: app/src/main/java/com/animeExplorer/ui/screens/splash/
- SplashScreen.kt: Beautiful YouTube-like splash screen with animations
- Features:
- Custom anime-themed logo with sparkle animations
- Smooth fade-in and scale animations
- Background gradient with animated sparkles
- 2.5-second duration with loading indicator
- Automatic transition to main app
- Animations: Alpha, scale, rotation, and infinite sparkle effects
- Design: Dark gradient background with white text and colorful sparkles
app/
βββ data/
β βββ local/ # Room database entities and DAOs
β β βββ AnimeEntity.kt
β β βββ AnimeDetailsEntity.kt
β β βββ AnimeDao.kt
β β βββ AnimeDetailsDao.kt
β β βββ AnimeDatabase.kt
β βββ remote/ # API service and DTOs
β β βββ ApiService.kt
β β βββ dto.kt
β βββ repository/ # Repository pattern implementation
β βββ AnimeRepository.kt
βββ di/ # Dependency injection modules
β βββ NetworkModule.kt
β βββ DatabaseModule.kt
β βββ RepositoryModule.kt
β βββ ViewModelModule.kt
βββ ui/
β βββ actions/ # UI actions and events
β β βββ animeList/
β β βββ animeDetails/
β βββ screens/ # Compose UI screens
β β βββ animeList/
β β βββ animeDetails/
β β βββ splash/
β βββ components/ # Reusable UI components
β β βββ TrailerPlayer.kt
β β βββ YouTubePlayer.kt
β β βββ SharedComponents.kt
β βββ theme/ # Material 3 theming
β βββ viewmodel/ # ViewModels with StateFlow
βββ util/ # App constants and utilities
β βββ AppConstants.kt
βββ MainActivity.kt # Main activity with navigation setup
GET /v4/top/anime
- Fetch top anime listGET /v4/anime/{id}
- Fetch anime detailsGET /v4/anime/{id}/characters
- Fetch anime characters
- Jetpack Compose - Modern UI toolkit
- Retrofit + OkHttp - Network requests with logging interceptor
- Coil - Image loading and caching
- Room + KSP - Local database with compile-time code generation
- Navigation Compose - Screen navigation
- ViewModel + StateFlow - State management
- Coroutines - Asynchronous programming
- Koin - Dependency injection
- android-youtube-player - YouTube video playback
- Material 3 - Modern design system
The app uses Koin for dependency injection with the following modules:
- NetworkModule: Provides Retrofit, OkHttp, and API service
- DatabaseModule: Provides Room database and DAOs
- RepositoryModule: Provides repository implementations
- ViewModelModule: Provides ViewModels
The app includes a sophisticated video player system:
- YouTubePlayer: Uses
android-youtube-player
library for YouTube video playback - TrailerPlayer: Wrapper component that handles both YouTube videos and poster fallbacks
- Error Handling: Graceful fallback to poster images when videos are unavailable
- Loading States: Proper loading indicators and error messages
- Image Fallback: If profile images become unavailable due to legal changes, the app gracefully falls back to placeholder images
- Network Resilience: App handles network failures and provides offline functionality
- Data Caching: Anime data is cached locally for offline access
- Error Recovery: Users can retry failed operations
- Responsive Design: UI adapts to different screen sizes
- Video Fallback: When trailers are unavailable, poster images are displayed with overlay text
- API Rate Limiting: Jikan API has rate limits that may affect performance
- Trailer Support: Only YouTube videos are supported; direct video URLs are not handled
- Character Images: Character profile images are not displayed due to potential legal constraints
- Search Functionality: No search feature implemented (focus on top anime list)
- Pagination: Only first page of anime results is loaded
- Orientation: App is locked to portrait mode for consistent video player experience
- Clone the repository
- Open in Android Studio
- Sync Gradle files
- Run on device or emulator
The app requires:
INTERNET
- For API callsACCESS_NETWORK_STATE
- For network status monitoring
The app provides full offline functionality:
- Cached anime list available without internet
- Detailed anime information stored locally
- Automatic sync when connection is restored
- Graceful error handling for network failures
- YouTube Integration: Seamless YouTube video playback
- Loading States: Proper loading indicators during video initialization
- Error Handling: Graceful error display with retry options
- Fallback System: Poster images displayed when videos are unavailable
- Lifecycle Management: Proper cleanup of video resources
- Koin Integration: Clean dependency injection setup with proper module organization
- State Management: Uses StateFlow for reactive UI updates
- Error Handling: Comprehensive error handling at all layers
- Code Organization: Well-structured with clear separation of concerns
- Documentation: Extensive code documentation with author attribution