A modern Android TV application built with Jetpack Compose, following MVVM architecture and using Retrofit for network operations. The app displays news articles from the GNews API.
This app follows the MVVM (Model-View-ViewModel) architecture pattern with the following layers:
- Models: Data classes representing the domain entities (e.g.,
News) - API Service: Retrofit interface for GNews API operations
- Local Database: Room database for offline news storage
- Repository: Single source of truth that combines local and remote data
- Repository Interface: Defines the contract for data operations
- Use Cases: Business logic operations (can be added as needed)
- ViewModels: Manage UI state and business logic
- Composables: Jetpack Compose UI components optimized for TV
- Screens: Complete screen implementations
- MVVM Architecture: Clean separation of concerns
- GNews API Integration: Real-time news from GNews API
- Room Database: Local news persistence
- Koin Dependency Injection: Clean dependency management
- Jetpack Compose for TV: Modern UI framework optimized for Android TV
- Coroutines & Flow: Asynchronous programming with reactive streams
- Coil: Efficient image loading
app/src/main/java/com/pmj/jaytv/
├── data/
│ ├── api/
│ │ └── NewsApiService.kt # GNews API interface
│ ├── local/
│ │ ├── AppDatabase.kt # Room database
│ │ └── NewsDao.kt # Data access object
│ ├── model/
│ │ └── News.kt # News data model
│ └── repository/
│ └── NewsRepository.kt # Repository implementation
├── di/
│ └── AppModule.kt # Koin module
├── ui/
│ ├── components/
│ │ └── NewsCard.kt # Reusable UI components
│ ├── screen/
│ │ └── HomeScreen.kt # Main screen implementation
│ ├── theme/
│ │ └── Theme.kt # App theming
│ └── viewmodel/
│ └── NewsViewModel.kt # ViewModel for news management
├── NewsFlowApplication.kt # Application class with Koin
└── MainActivity.kt # Main activity
- Jetpack Compose for TV: UI framework
- Koin: Dependency injection
- Retrofit: Network communication with GNews API
- Room: Local database
- Coroutines: Asynchronous programming
- Coil: Image loading
- Android Studio Hedgehog or later
- Android SDK 23+ (target: 35)
- Kotlin 1.9.22+
The app uses the new Gradle Version Catalogs (libs.versions.toml) for dependency management.
- Clone the repository
- Open in Android Studio
- Sync Gradle files
- Run on Android TV emulator or device
To use the GNews API:
- The base URL is already configured in
NetworkModule.kt:
baseUrl("https://gnews.io/api/v4/")- Add your GNews API key in local.properties:
GNEWS_API_KEY = "your_api_key"The app uses Room database with the following entity:
id: Primary key (String)title: News article titledescription: News article descriptioncontent: News article contenturl: Article URLimage: Article image URLpublishedAt: Publication datesourceName: News source namesourceUrl: News source URLisFavorite: Favorite statustimestamp: Creation timestamp
- TV-optimized card component for news articles
- Focus handling for remote navigation
- Image, title, description, and source display
- Favorite toggle functionality
- Publication date formatting
- Main screen with news grid
- Search functionality for news articles
- Top headlines section
- Favorite news section
- Loading and error states
The app currently uses a single-activity architecture with Compose navigation. When a news article is clicked, it opens in the device's default browser.
- Lazy Loading: News articles are loaded in chunks
- Image Caching: Coil handles efficient image loading
- Database Optimization: Room with Flow for reactive updates
- Memory Management: Proper lifecycle management in ViewModels
This project is licensed under the MIT License - see the LICENSE file for details.
