Skip to content

FusionWorks/kotlin-mvvm-poc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Android MVVM Architecture with Kotlin

This project demonstrates modern Android development using MVVM architecture pattern with Kotlin, migrated from the original MVP Java implementation.

πŸ—οΈ Architecture

  • MVVM Architecture: Model-View-ViewModel pattern with Repository pattern
  • Language: 100% Kotlin
  • Minimum SDK: 24 (Android 7.0)
  • Target SDK: 34 (Android 14)

πŸ› οΈ Tech Stack

Core

  • Kotlin: Primary programming language
  • Coroutines: For asynchronous programming
  • Flow: For reactive programming
  • Hilt: Dependency injection
  • ViewBinding: Type-safe view references

Architecture Components

  • ViewModel: UI-related data holder with lifecycle awareness
  • LiveData & StateFlow: Observable data holder classes
  • Room: Database abstraction layer
  • Repository Pattern: Single source of truth for data

Networking

  • Retrofit: HTTP client for API calls
  • OkHttp: HTTP & HTTP/2 client
  • Moshi: JSON library for Kotlin

UI

  • Material Design Components: Modern UI components
  • RecyclerView: List implementation with ListAdapter
  • ViewPager2: Modern paging implementation
  • Navigation Component: App navigation

Testing

  • JUnit: Unit testing framework
  • Espresso: UI testing framework
  • Mockito: Mocking framework

Build System

  • Gradle Version Catalogs: Centralized dependency management
  • Kotlin DSL: Modern build script syntax

πŸ“¦ Module Structure

app/
β”œβ”€β”€ src/main/kotlin/com/mindorks/framework/mvvm/
β”‚   β”œβ”€β”€ data/
β”‚   β”‚   β”œβ”€β”€ local/
β”‚   β”‚   β”‚   β”œβ”€β”€ database/        # Room database implementation
β”‚   β”‚   β”‚   └── prefs/           # SharedPreferences wrapper
β”‚   β”‚   β”œβ”€β”€ network/             # API interfaces and implementations
β”‚   β”‚   β”œβ”€β”€ repository/          # Data repository implementations
β”‚   β”‚   └── model/               # Data models
β”‚   β”œβ”€β”€ ui/
β”‚   β”‚   β”œβ”€β”€ base/                # Base classes for Activities/Fragments/ViewModels
β”‚   β”‚   β”œβ”€β”€ main/                # Main screen with question cards
β”‚   β”‚   β”œβ”€β”€ login/               # Login functionality
β”‚   β”‚   β”œβ”€β”€ splash/              # Splash screen
β”‚   β”‚   └── feed/                # Feed screens (blogs/open source)
β”‚   β”œβ”€β”€ utils/                   # Utility classes
β”‚   └── MvvmApp.kt              # Application class
β”œβ”€β”€ src/debug/                   # Debug-only code (Flipper, database inspection)
└── src/test/                    # Unit tests

πŸš€ Key Features

Modern Android Development

  • Kotlin Coroutines: Replaces RxJava for simpler async code
  • Room Database: Replaces GreenDAO with better Kotlin support
  • Modern Networking: Retrofit + Coroutines for API calls
  • Type Safety: Leverages Kotlin's type system for safer code

Legacy Library Replacements

  • βœ… AndroidNetworking β†’ Retrofit + OkHttp
  • βœ… Calligraphy β†’ Native Font Resources
  • βœ… PlaceHolderView β†’ RecyclerView + ListAdapter
  • βœ… Debug-DB β†’ Flipper (debug builds)
  • βœ… RxJava β†’ Kotlin Coroutines + Flow

Enhanced Features

  • Swipe Cards: Custom swipe implementation for question cards
  • Modern Adapters: ListAdapter with DiffUtil for efficient updates
  • Network Error Handling: Comprehensive error handling with sealed classes
  • Debug Tools: Flipper integration for debugging (debug builds only)

πŸ”§ Setup

Prerequisites

  • Android Studio Arctic Fox or later
  • JDK 17 or later
  • Android SDK 34

Getting Started

  1. Clone the repository
git clone https://github.com/your-username/android-mvvm-architecture.git
  1. Open the project in Android Studio

  2. Sync project with Gradle files

  3. Run the app

Build Configuration

The project uses Gradle Version Catalogs for dependency management. All dependencies are defined in gradle/libs.versions.toml.

πŸ§ͺ Testing

Unit Tests

./gradlew test

Instrumentation Tests

./gradlew connectedAndroidTest

πŸ› Debug Tools

Debug Builds

Debug builds include additional tools:

  • Flipper: Network and database inspection
  • LeakCanary: Memory leak detection
  • Debug Activity: Database inspection and export

Access Debug Menu

In debug builds, you can access debug tools through the navigation drawer or by directly starting the DebugActivity.

πŸ—οΈ Migration from MVP

This project was migrated from MVP (Java) to MVVM (Kotlin). Key migration points:

Architecture Changes

  • Presenters β†’ ViewModels
  • View Interfaces β†’ LiveData/StateFlow observers
  • Manual lifecycle management β†’ Automatic lifecycle awareness

Technology Updates

  • Java β†’ Kotlin
  • RxJava β†’ Coroutines + Flow
  • GreenDAO β†’ Room
  • Legacy networking β†’ Modern Retrofit

Code Quality Improvements

  • Type safety with Kotlin
  • Null safety
  • Coroutines for cleaner async code
  • Modern Android Architecture Components

πŸ“š Learning Resources

πŸ“„ License

Copyright (C) 2017 MINDORKS NEXTGEN PRIVATE LIMITED

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    https://mindorks.com/license/apache-v2

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“ž Support

For questions and support, please visit:


Happy Coding! πŸŽ‰

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 13