我正在创建一个代码模板来加快我的工作。该模板工作正常,如下所示
class SimpleActivity : AppActivity<ActivitySimpleBinding, SimpleActivityViewModel>() {
override fun layoutID(): Int = R.layout.activity_simple
override fun setViewModel(): SimpleActivityViewModel {
val mViewModel: SimpleActivityViewModel by viewModels()
return mViewModel
}
}
唯一的问题是在使用我的模板时编写正确的App packageName 。我能摆脱它吗。是否有任何默认方法可以在模板中选择它
<?xml version="1.0"?>
<template
format="5"
revision="3"
name="MVVM Activity"
description="Creates a Activity with a ViewModel."
minApi="7"
minBuildApi="21">
<category value="Activity" />
<formfactor value="Mobile" />
<parameter
id="activityClass"
name="Activity Name"
type="string"
constraints="class|nonempty|unique"
default="BlankActivity"
help="The name of the fragment class to create" />
<parameter
id="layoutName"
name="Activity Layout Name"
type="string"
constraints="layout|nonempty|unique"
default="blank_activity"
suggest="${classToResource(activityClass)}_activity"
help="The name of the layout to create" />
<parameter
id="viewModelName"
name="ViewModel Name"
type="string"
constraints="class|nonempty|unique"
default="BlankViewModel"
suggest="${underscoreToCamelCase(classToResource(activityClass))}ViewModel"
help="The name of the ViewModel class to create" />
<parameter
id="appPackageName"
name="app Package name"
type="string"
constraints="package"
default="how.to.get.default.package.here"
help="app package name" />
<thumbs>
<thumb>template_blank_fragment.png</thumb>
</thumbs>
<globals file="globals.xml.ftl" />
<execute file="recipe.xml.ftl" />
</template>
请参阅下面的appPackageName。有没有办法在这里设置默认包名或在AppActivity.kt.ftl中获取 appPackage 名称
<parameter
id="appPackageName"
name="app Package name"
type="string"
constraints="package"
default="how.to.get.default.package.here"
help="app package name" />
我想删除上面的参数或者在这里自动设置默认的项目包。
有没有办法实现它。