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.properties
or use aBuildConfig
field. -
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.