神奇宝贝 (PokemonGo) 基于 Jetpack + MVVM + Repository + Paging3 + Kotlin Flow 的实战项目

Overview

PokemonGo

神奇宝贝 (PokemonGo) 基于 Jetpack + MVVM + Repository + Paging3 + Kotlin Flow 的实战项目

这是一个小型的 App 项目,涉及到技术:Paging3(network + db),Dagger-Hilt,App Startup,DataBinding,Room,Motionlayout,Kotlin Flow,Coil,JProgressView 等等。

GitHub Stars GitHub Forks

PokemonGo 动态效果图如下所示,如果动图无法查看,请点击这里查看 动态效果图 | 静态图

PokemonGo 更新记录

2020-12-05:

  • upgrad kotlin plugin to 1.4.2
  • delete Kotlin synthetics
  • delete kotlin-android-extensions

2020-09-27:

  • 使用 ConflatedBroadcastChannel 实现 DB 搜索
  • 使用 StateFlow 实现 NetWork 搜索
  • 增加了 Kotlin 常用操作符 debouncefilterflatMapLatestdistinctUntilChanged 的使用

以上更新对应分析文章:

2020-07-26:

  • 增加了使用 sealed 在 Flow 基础上封装成功或者失败处理
  • 自定义 RemoteMediator 实现数据库网络加载数据( RemoteMediator 是 Paging3 当中重要成员 )

以上更新对应分析文章:

2020-07-23:

  • Flow 在 MVVM 当中的使用
  • Activity 、Fragment、ViewModel 结合 Flow 三种使用方式
  • Flow 的异常处理
  • 增加 Fragment 1.2.0 上重要的更新: 通过 Fragment 的构造函数传递参数,以及 FragmentFactory 和 FragmentContainerView 的使用
  • ......

以上更新对应分析文章:

2020-07-14:

  1. 自定义 RemoteMediator 实现 network + db 的混合使用 ( RemoteMediator 是 Paging3 当中重要成员 )
  2. 使用 Data Mapper 分离数据源 和 UI
  3. Kotlin Flow 结合 Retrofit2 + Room 的混合使用
  4. Kotlin Flow 与 LiveData 的使用
  5. 使用 Coil 加载图片
  6. 使用 ViewModel、LiveData、DataBinding 协同工作
  7. 使用 Motionlayout 做动画
  8. App Startup 与 Hilt 的使用
  9. ......

关于 PokemonGo 项目分析的文章请查看 神奇宝贝 眼前一亮的 Jetpack + MVVM 极简实战

如果这个仓库对你有帮助,请仓库右上角帮我 star 一下,非常感谢。

项目 PokemonGo 涉及到的技术

  • Gradle Versions Plugin:检查依赖库是否存在最新版本
  • Kotlin Flow:flow 是对 Kotlin 协程的扩展,让我们可以像运行同步代码一样运行异步代码
  • JetPack
    • Paging3(network + db):用到了 Paging3 中的 RemoteMediator 用来实现 network + db
    • Dagger-Hilt (2.28-alpha):依赖注入框架
    • App Startup:设置组件初始化顺序
    • DataBinding:以声明方式将可观察数据绑定到界面上
    • Room:在 SQLite 上提供了一个抽象层,流畅地访问 SQLite 数据库
    • LiveData:在底层数据库更改时通知视图
    • ViewModel:以注重生命周期的方式管理界面相关的数据
    • Andriod KTX:编写更简洁、惯用的 Kotlin 代码
  • 项目架构
    • MVVM 架构
    • Repository 设计模式
    • Data Mapper 数据映射
  • Retrofit2 & OkHttp3:用于请求网路数据
  • Coil:基于 Kotlin 开发的首个图片加载库
  • material-components-android:模块化和可定制的材料设计 UI 组件
  • Motionlayout :MotionLayout 是一种布局类型,可帮助您管理应用中的动画
  • Timber: 日志打印
  • JProgressView :一个小巧灵活可定制的进度条,支持图形:圆形、圆角矩形、矩形等等

以上技术栈对应之前写的技术文章:

如何检查依赖库的版本更新

在项目的根目录下执行以下命令。

./gradlew dependencyUpdates

会在当前目录下生成 build/dependencyUpdates/report.txt 文件,内容如下所示:

The following dependencies have later release versions:
 - androidx.swiperefreshlayout:swiperefreshlayout [1.0.0 -> 1.1.0]
     https://developer.android.com/jetpack/androidx
 - com.squareup.okhttp3:logging-interceptor [3.9.0 -> 4.7.2]
     https://square.github.io/okhttp/
 - junit:junit [4.12 -> 4.13]
     http://junit.org
 - org.koin:koin-android [2.1.5 -> 2.1.6]
 - org.koin:koin-androidx-viewmodel [2.1.5 -> 2.1.6]
 - org.koin:koin-core [2.1.5 -> 2.1.6]

Gradle release-candidate updates:
 - Gradle: [6.1.1 -> 6.5.1]

会列出所有需要更新的依赖库的最新版本,并且 Gradle Versions Plugin 比 AndroidStudio 所支持的更加全面:

  • 支持手动方式管理依赖库最新版本检查
  • 支持 ext 的方式管理依赖库最新版本检查
  • 支持 buildSrc 方式管理依赖库最新版本检查
  • 支持 gradle-wrapper 最新版本检查
  • 支持多模块的依赖库最新版本检查
  • 支持多项目的依赖库最新版本检查

MVVM 架构

PokemonGo 基于 MVVM 架构和 Repository 设计模式,如今几乎所有的 Android 开发者至少都听过 MVVM 架构,在谷歌 Android 团队宣布了 Jetpack 的视图模型之后,它已经成为了现代 Android 开发模式最流行的架构之一。

Jetpack 的视图模型的 MVVM 架构由 View + DataBinding + ViewModel + Model 组成。

TODO

  • 加入更多 Jetpack 成员
  • 设计更多的实用场景
  • 增加单元测试
  • 增加 Motionlayout 的使用
  • ......

联系我

  • 个人微信:hi-dhl
  • 公众号:ByteCode,包含 Jetpack ,Kotlin ,Android 10 系列源码,译文,LeetCode / 剑指 Offer / 多线程 / 国内外大厂算法题 等等一系列文章


最后推荐我一直在更新维护的项目和网站:

  • 计划建立一个最全、最新的 AndroidX Jetpack 相关组件的实战项目 以及 相关组件原理分析文章,正在逐渐增加 Jetpack 新成员,仓库持续更新,欢迎前去查看:AndroidX-Jetpack-Practice

  • LeetCode / 剑指 offer / 国内外大厂面试题 / 多线程 题解,语言 Java 和 kotlin,包含多种解法、解题思路、时间复杂度、空间复杂度分析

  • 最新 Android 10 源码分析系列文章,了解系统源码,不仅有助于分析问题,在面试过程中,对我们也是非常有帮助的,仓库持续更新,欢迎前去查看 Android10-Source-Analysis

  • 整理和翻译一系列精选国外的技术文章,每篇文章都会有译者思考部分,对原文的更加深入的解读,仓库持续更新,欢迎前去查看 Technical-Article-Translation

  • 「为互联网人而设计,国内国外名站导航」涵括新闻、体育、生活、娱乐、设计、产品、运营、前端开发、Android 开发等等网址,欢迎前去查看 为互联网人而设计导航网站

感谢

中文:

English:

You might also like...
Android App made by Jetpack Compose Components with Kotlin, MVVM Pattern, Multi Module, Navigation, Hilt, Coroutines, Retrofit and cached data by Room
Android App made by Jetpack Compose Components with Kotlin, MVVM Pattern, Multi Module, Navigation, Hilt, Coroutines, Retrofit and cached data by Room

Mobile Banking Android App made by Jetpack Compose Components with Kotlin, MVVM Pattern, Multi Module, Navigation, Hilt, Coroutines, Retrofit and cach

📝   Note List app based on MVVM architecture (ViewModel, LiveData, Coroutines, Room and Jetpack Compose)
📝 Note List app based on MVVM architecture (ViewModel, LiveData, Coroutines, Room and Jetpack Compose)

Note list app built with Jetpack Compose Download Go to the releases page to download the latest available apk. Screenshots Architecture Features Home

Android weather app using Hilt, Coroutines, Retrofit, Jetpack (Compose, Room, ViewModel) based on MVVM architecture
Android weather app using Hilt, Coroutines, Retrofit, Jetpack (Compose, Room, ViewModel) based on MVVM architecture

Atmostate A weather app written with Jetpack Compose using OpenWeatherMap Get the APK Features offline caching fetching data for current user location

A Native Andorid App developed in Jetpack Compose MVVM architecture
A Native Andorid App developed in Jetpack Compose MVVM architecture

Astronomy Picture of the Day This is a Native Andorid App developed in Jetpack Compose MVVM architecture, To view the Astronomy Picture of the day fro

FullMangement - an application that helps you manage your tasks effectively. built with the latest tachs like Compose UI, Jetpack libraries, and MVVM design pattern.
FullMangement - an application that helps you manage your tasks effectively. built with the latest tachs like Compose UI, Jetpack libraries, and MVVM design pattern.

Full Management is an application that helps you manage your tasks effectively. built with the latest tachs like Compose UI, Jetpack libraries and MVVM design pattern.

ToDo-Task-App - An Android App built to demonstrate the use of Jetpack Compose, Material You, Room Database, and MVVM

ToDo Task App ToDo Task App is a sample Android app built with Jetpack Compose.

Animal-Kingdom - CLEAN Architecture with MVVM and Jetpack-Compose
Animal-Kingdom - CLEAN Architecture with MVVM and Jetpack-Compose

CLEAN Architecture with MVVM and Jetpack-Compose. About the app I have created t

 Android Clean Architecture with MVVM using Jetpack component
Android Clean Architecture with MVVM using Jetpack component

Android Clean Architecture with MVVM using Jetpack component 💡 What is Clean Architecture? Clean architecture is a category of software design patter

Kotlin-MVVM-RxJava-Hilt-Retrofit-Room

IMovie IMovie is a is a sample project that presents a modern approach to Android application development. The goal of the project is to combine popul

Comments
  • [剽竊] Copied project

    [剽竊] Copied project

    This project seems almost copied code from Pokedex but there is no marked?

    And I just wonder why did you remove and change every of his libraries and license..? Furthermore, Your library JDataBinding seems plagiarized almost codes. I didn't look into details of codes but JProgressView also similar.

    cc. @skydoves

    opened by rurimo 3
  • 构建出错

    构建出错

    环境:as4.0.1 & gradle-6.5-bin (其他与项目一致)

    代码版本:feb32d0 on 6 Dec 2020

    问题:databinding辅助类【com.hi.dhl.pokemon.databinding.ActivityMainBindingImpl】中 MotionCoordinatorlayoutHeaderBinding layoutHeader构建出错

    解决:【app/src/main/res/layout/motion_coordinatorlayout_header.xml】 alt+enter 转为 databinding 布局可正常构建

    opened by stubhbw 1
Owner
Jack Deng
公众号:ByteCode,致力于分享最新技术原创文章,涉及 Kotlin 、Jetpack 、译文 、系统源码 、 LeetCode / 剑指 Offer / 多线程 / 国内外大厂算法题 等等一系列文章。如果你同我一样喜欢 coding,一起来学习,期待与你一起成长...
Jack  Deng
Android Clean Architecture That Screams (MVVM + JetPack Compose UI + Flow + State)

Android Clean Architecture That Screams (MVVM + JetPack Compose UI + Flow + State)

Praveen Sharma 9 May 11, 2022
A Simple Blog App using Jetpack Compose, Flow, Navigation Compose, Room and Firebase

BlogCompose A Simple Blog App using Jetpack Compose, Flow, Navigation Compose, Room and Firebase Instructions Download your Firebase configuration fil

null 4 Oct 10, 2022
This repository is a playground of jetpack compose for android developers

Pritesh Jetpack Compose This repository is a playground of jetpack compose for Android Developers, I tried to get my hands dirty with challenging UI t

PriteshVadhiya 5 Apr 20, 2022
A simple authentication application using Jetpack compose to illustrate signin and sign up using Mvvm, Kotlin and jetpack compose

Authentication A simple authentication application using Jetpack compose to illustrate signin and sign up using Mvvm, Kotlin and jetpack compose Scree

Felix Kariuki 5 Dec 29, 2022
You can learn how to create multi module Android project with this repository.

MultiModuleProjectSample You can learn how to create multi module Android project with this repository. You can read this article in Turkish. Go to th

Adem ATİCİ 9 Nov 6, 2022
Kotlin, MVVM, Navigation Component, Hilt, Jetpack Compose, Retrofit2

What is this project? This course will replace my old java mvvm introduction: https://codingwithmitch.com/courses/rest-api-mvvm-retrofit2/. Watch the

Mitch Tabian 452 Jan 1, 2023
Burak Akgün 84 Oct 30, 2022
Android -MVVM-Jetpack Compose-Kotlin Flows-Dagger Hilt-Retrofilt2-Coil

android-mvvm-jetpack-compose-kotlin-flows Android -MVVM-Jetpack Compose-Kotlin Flows-Dagger Hilt-Retrofilt2-Coil A sample project that presents a mode

Emad Seliem 8 Jul 27, 2022
Navigation-Compose - A sample to showcase Kotlin, MVVM, Hilt, Coroutines, StateFlow, Jetpack compose

Navigation-Compose A sample to showcase Kotlin, MVVM, Hilt, Coroutines, StateFlo

Mohammadali Rezaei 6 Jul 13, 2022
Android App made by Jetpack Compose Components with Kotlin, MVVM Pattern, Multi Module, Navigation, Hilt, Coroutines, Retrofit and cached data by Room

Android App made by Jetpack Compose Components with Kotlin, MVVM Pattern, Multi Module, Navigation, Hilt, Coroutines, Retrofit and cached data by Room

Yogi Dewansyah 13 Aug 31, 2022