explaingit

kunminx/jetpack-mvvm-best-practice

8,939JavaAudience · developerComplexity · 3/5LicenseSetup · moderate

TLDR

A sample Android music player app that shows Java developers how to correctly use Google Jetpack components like ViewModel, LiveData, and Navigation without common mistakes.

Mindmap

mindmap
  root((jetpack-mvvm))
    What it does
      MVVM sample app
      Music player demo
      Jetpack best practices
    Tech Stack
      Java
      Android Jetpack
      ViewModel
      LiveData
    Architecture
      UI layer
      ViewModel layer
      DataRepository
    Use Cases
      Learn Jetpack patterns
      Reference architecture
      Avoid memory leaks
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Learn how to wire Jetpack ViewModel and LiveData together in an Android app without memory leaks or errors.

USE CASE 2

Use as a reference architecture for building an Android app with layered UI, ViewModel, and DataRepository structure.

USE CASE 3

Implement safe screen rotation handling and inter-screen messaging in an Android Jetpack project.

Tech stack

JavaAndroidJetpackViewModelLiveDataNavigationDataBinding

Getting it running

Difficulty · moderate Time to first run · 30min

Requires Android Studio and a connected Android device or emulator to run the sample.

Free to use, modify, and distribute for any purpose including commercial use, with attribution.

In plain English

This is an Android sample application that demonstrates how to use Google's Jetpack MVVM architecture correctly and without common mistakes. The README is written in Chinese, and the project is aimed at Android developers who want a clear, working example of how Jetpack components fit together, rather than yet another article that pastes disconnected code snippets. Jetpack is a collection of Android libraries from Google covering things like ViewModel (which stores screen state across configuration changes), LiveData (which notifies the UI when data changes), Navigation (which manages screen transitions), and DataBinding (which connects layout files directly to data). The project shows how to wire these pieces together in a way that avoids memory leaks and unpredictable errors, particularly when switching between portrait and landscape layouts or when sending messages between different screens. The sample app takes the form of a music player, similar in appearance to Tencent's lighter music app. It demonstrates portrait-to-landscape layout switching with no unexpected errors, a unified event distribution system using LiveData and shared ViewModels, and a layered architecture where the UI layer talks to the ViewModel layer, which in turn talks to a DataRepository, with no reverse dependencies. The project avoids dependency injection tools like Dagger and explicitly states the goal is readable, maintainable code rather than clever tricks. The code is written entirely in Java and is licensed under the Apache License 2.0. According to a survey in the README, the architecture patterns shown here have been referenced or adopted by software teams at Tencent Music, NetEase Cloud Music, TCL, BMW, and several other companies. The app is available to download and try directly from app stores.

Copy-paste prompts

Prompt 1
Based on the jetpack-mvvm-best-practice architecture, show me how to add a new screen with its own ViewModel and LiveData observing a DataRepository.
Prompt 2
How does jetpack-mvvm-best-practice handle sending one-time events from a ViewModel to the UI without misusing LiveData?
Prompt 3
Show me how DataBinding is set up in the jetpack-mvvm-best-practice music player to connect a layout file to a ViewModel without boilerplate.
Prompt 4
How does this project handle portrait-to-landscape rotation without losing screen state or triggering unexpected errors?
Open on GitHub → Explain another repo

← kunminx on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.