Skip to content

6、文件模板

imyyq edited this page Aug 10, 2020 · 3 revisions

文件模板

为了减少样板代码,可以使用 AS 提供的 File Template 和 Live Template。

可通过 File | Import Settings 导入框架根目录下的 templates.zip,即可在 File | New 菜单中看到框架的文件模板:

图1

快速创建项目通用结构

在 Sample 里,目录结构如下:

app
data
    source
        http
            service
                DemoApiService
            HttpDataSourceImpl
        local
            LocalDataSourceImpl
        HttpDataSource
        LocalDataSource
    DemoRepository
entity
    DemoEntity
ui
    MainActivity
    MainViewModel
utils

可通过框架根目录下的 create_templates.groovy 自动生成如上目录,具体使用方法详见 create_templates.groovy 文件的注释