A modern Kotlin-based Android news app that follows the MVVM architecture and emphasizes offline-first functionality. The app fetches news data from a REST API, displays it in a responsive UI, and stores it locally using Room, allowing users to access news even without an internet connection.
- π‘ Fetches latest news articles from an API
- πΎ Offline-first: Caches data using Room for offline access
- β‘ Smooth and efficient UI with FastAdapter
- π Automatic updates with LiveData and Coroutines
- π View articles in detail or in a web view
- π Proper architecture with separation of concerns
| Layer | Libraries/Technologies |
|---|---|
| Language | Kotlin |
| Architecture | MVVM, LiveData, ViewModel, Data Binding |
| Networking | Retrofit, Moshi, Kotlin Coroutines |
| Local Storage | Room |
| UI Components | FastAdapter, Material Components |
| Utilities | Android KTX, Lifecycle Components |
com.gshoai998.newsapp
βββ model
β βββ api
β β βββ ApiService.kt
β β βββ RetrofitClient.kt
β βββ database
β β βββ NewsDAO.kt
β β βββ NewsDatabase.kt
β βββ DataClasses.kt # Data models for API and DB
βββ repo
β βββ NewsRepository.kt # Repository managing data sources
βββ utils
β βββ Constants.kt
β βββ NetworkUtils.kt
βββ view
β βββ activities
β β βββ MainActivity.kt
β β βββ OfflineActivity.kt
β β βββ ArticleDetailActivity.kt
β β βββ ArticleWebViewActivity.kt
β βββ ArticleItem.kt # FastAdapter item for displaying articles
β βββ BindingAdapters.kt # Custom Data Binding adapters
β βββ viewModel
β βββ NewsViewModel.kt
β βββ NewsViewModelFactory.kt
- Android Studio Giraffe or later
- Android SDK 33+
- Kotlin 1.9+
- Internet connection (for initial API calls)
-
Clone the repository:
git clone https://github.com/Shoaibkhalid65/NewsApp.git cd OfflineNewsApp -
Open in Android Studio
- File > Open > Select the project directory
-
Add your API key
If the API requires a key, add it in a secure place like
local.propertiesor use aBuildConfigfield. -
Build and Run
- Select a device/emulator and click Run
βΆοΈ
- Select a device/emulator and click Run
newsapp_vid.mp4
This app uses the MVVM pattern to ensure a clean separation of concerns:
- Model (Data layer): Handles networking (Retrofit + Moshi) and local storage (Room).
- ViewModel: Exposes observable data using LiveData and handles logic with Coroutines.
- View: Activities and layout files bind to data using Data Binding and FastAdapter for smooth list rendering.
Contributions are welcome! If you'd like to improve something or report a bug:
- Fork the repository
- Create a feature/bugfix branch
- Push your changes and open a Pull Request
This project is licensed under the MIT License.
Developed by Muhammad Shoaib Khalid Inspired by clean architecture and modern Android development practices.