MVVM_Android-CleanArchitecture 项目教程

MVVM_Android-CleanArchitecture 项目教程

MVVM_Android-CleanArchitecture项目地址:https://gitcode.com/gh_mirrors/mv/MVVM_Android-CleanArchitecture

1. 项目的目录结构及介绍

MVVM_Android-CleanArchitecture/
├── app/
│   ├── build.gradle
│   ├── src/
│   │   ├── main/
│   │   │   ├── java/
│   │   │   │   ├── com.zhengxiaopeng.mvvm/
│   │   │   │   │   ├── data/
│   │   │   │   │   ├── di/
│   │   │   │   │   ├── domain/
│   │   │   │   │   ├── presentation/
│   │   │   │   │   ├── utils/
│   │   │   │   │   ├── App.kt
│   │   │   ├── res/
│   │   │   │   ├── drawable/
│   │   │   │   ├── layout/
│   │   │   │   ├── mipmap/
│   │   │   │   ├── values/
│   │   ├── test/
│   │   ├── androidTest/
├── build.gradle
├── settings.gradle

目录结构介绍

  • app/: 主应用程序模块。
    • build.gradle: 应用程序的构建脚本。
    • src/: 源代码目录。
      • main/: 主源代码目录。
        • java/: Java 源代码目录。
          • com.zhengxiaopeng.mvvm/: 主包目录。
            • data/: 数据层,包含数据源、仓库等。
            • di/: 依赖注入配置。
            • domain/: 领域层,包含业务逻辑和用例。
            • presentation/: 表示层,包含视图和 ViewModel。
            • utils/: 工具类。
            • App.kt: 应用程序的入口类。
        • res/: 资源目录。
          • drawable/: 可绘制资源。
          • layout/: 布局文件。
          • mipmap/: 图标资源。
          • values/: 字符串、颜色等资源。
      • test/: 单元测试目录。
      • androidTest/: 仪器测试目录。
  • build.gradle: 根项目的构建脚本。
  • settings.gradle: 项目设置脚本。

2. 项目的启动文件介绍

App.kt

package com.zhengxiaopeng.mvvm

import android.app.Application
import com.zhengxiaopeng.mvvm.di.AppModule
import org.koin.android.ext.koin.androidContext
import org.koin.core.context.startKoin

class App : Application() {
    override fun onCreate() {
        super.onCreate()
        startKoin {
            androidContext(this@App)
            modules(AppModule)
        }
    }
}

介绍

  • App.kt: 应用程序的入口类,继承自 Application
  • onCreate(): 应用程序启动时调用的方法,初始化 Koin 依赖注入框架。

3. 项目的配置文件介绍

build.gradle (根项目)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.5.21'
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

介绍

  • buildscript: 配置构建脚本依赖。
    • ext.kotlin_version: Kotlin 版本。
    • repositories: 仓库配置。
    • dependencies: 构建脚本依赖。
  • **allprojects

MVVM_Android-CleanArchitecture项目地址:https://gitcode.com/gh_mirrors/mv/MVVM_Android-CleanArchitecture

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

倪炎墨

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值