Introduction

This project is a learning type project, mainly to learn some of the latest ideas and development ideas of Android. The project is developed according to the development ideas of modularization and componentization. The overall structure of the project is as follows.
image.png

The project code is clean and standardized, with a clear structure, using the latest Android development ideas and technologies, and integrating React-Native cross-platform, mainly for the purpose of experimenting with hot update functions. The technologies involved are as follows:

  1. Developed using kotlin language, the project uses modular development, which reduces coupling;
  2. The network uses the retrofit2 + okhttp3 method, which is highly encapsulated;
  3. leakcanary memory leak detection
  4. Mavericks based on MVI architecture airbnb
  5. local mock
  6. alibaba ARouter
  7. Integrated RN hot update function, the user needs to open the rn loading page, please refer to the rn project

experience

Some of the effects are as follows:
image.png
image.png
image.png

MVI Architecture

image.png
With no clear standard for state management, view rendering and business logic can get a bit messy as the app grows or features are added or not planned in advance, and this often happens during Android app development. Maybe you often encounter state management that leads to unclear division of labor between business logic and UI rendering, and ultimately leads to confusion in the application architecture. The newly proposed MVI architecture advocates a design idea of one-way data flow, which is very suitable for data-driven UI display projects. The architectural idea of MVI comes from the front end, which is composed of three parts: Model, View and Intent.

  • Model: Different from the Model in other MVVM, the Model of MVI mainly refers to the UI state (State). The content displayed on the current interface is nothing more than a snapshot of the UI state: for example, the data loading process, the location of controls, etc. are all UI states
  • View: Consistent with other Views in MVX, it may be an Activity, Fragment or any UI bearing unit. View in MVI achieves interface refresh by subscribing to changes in Intent (not Activity's Intent, which will be introduced later)
  • Intent: This Intent is not an Activity's Intent. Any operation of the user is packaged as an Intent and sent to the Model for data request

Third-party libraries used

library Function
retrofit2 network
okHttp3 network
mavericks MVI framework
BaseRecyclerViewAdapterHelper Universal Adapter
PhotoView Picture Preview
ARouter componentized routing
coil image loading
XPopup popup component
banner scroll map
SmartRefreshLayout Smart pull-to-refresh framework
gson json parsing
leakcanary Memory leak detection library

Attachment: https://github.com/GuoguoDad/jd_mall


xiangzhihong
5.9k 声望15.3k 粉丝

著有《React Native移动开发实战》1,2,3、《Kotlin入门与实战》《Weex跨平台开发实战》、《Flutter跨平台开发与实战》1,2和《Android应用开发实战》