Skip to content

Commit

Permalink
支持移除已转换的layout文件,修复缓存复用错误
Browse files Browse the repository at this point in the history
  • Loading branch information
duduhuang88 committed Dec 25, 2022
1 parent b2ea423 commit 7dd510e
Show file tree
Hide file tree
Showing 41 changed files with 659 additions and 193 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Gradle 5.6.4 以上
```groovy
buildscript {
...
ext.qxml_version = "3.3.0"
ext.qxml_version = "3.4.0"
repositories {
...
mavenCentral()
Expand Down Expand Up @@ -149,6 +149,16 @@ qxml {
ignoreUnImplementAttr true //是否忽略未实现的属性,默认true
useCreateViewListener true //使用createViewListener,默认false
checkMethod false //是否检查View属性配置变化进行重新生成,设置false可提高transform速度,默认false,如果修改/自定义View属性时设置为false需删除缓存(build/qxml或clean)
//3.4.0起支持移除已转换layout文件
//在root build.gradle同级目录中可创建qxmlRemoveLayoutWhiteList.txt白名单文件,内容格式为layout文件名,按行读取,eg:
/*
activity_main
imageview_test
*/
//开启后会自动保留转换失败的layout所关联的layout文件,但未经qxml处理的layout文件需在白名单文件中声明,如动态创建的ViewStub#setLayoutResource引用的layout文件
removeConvertedLayout false
//以上为默认设置
/*buildType {
debug { //单独配置debug,没有设置的值会使用默认设置
Expand Down Expand Up @@ -199,7 +209,7 @@ QXML_LOG_ENABLE = true/false : 是否开启annotationProcesser的log

#### 2. ~~增加编译时间~~,首次编译根据 layout 数量和复杂度增长,而后会使用缓存

#### 3. 增加 apk 体积,在 demo 中 52 个 layout 文件时,release apk 体积增加了约 38K,后续可能会添加重打包移除已转换 layout 文件的选项
#### 3. 增加 apk 体积,在 demo 中 52 个 layout 文件时,release apk 体积增加了约 38K,~~后续可能会添加重打包移除已转换 layout 文件的选项~~,3.4.0已实装,开启后请进行充分测试,将动态引用的layout文件加入白名单

#### 4. ~~目前扩展 View 需使用全限定类名,后续可能会改善这种情况~~,除定义共享变量外已无需全限定类名

Expand Down
9 changes: 7 additions & 2 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Gradle 5.6.4 above
```groovy
buildscript {
...
ext.qxml_version = "3.3.0"
ext.qxml_version = "3.4.0"
repositories {
...
mavenCentral()
Expand Down Expand Up @@ -134,6 +134,11 @@ qxml {
ignoreUnImplementAttr //ignore unImplement attr or not, default value: true
useCreateViewListener true //using createViewListener, default value: false
checkMethod false //default value: false, check the view attr method change when building, you should set true when custom view attr
//remove converted layout file or not,support since 3.4.0,default value: false,you can create qxmlRemoveLayoutWhiteList.txt file in project root dir, the content is layout file name,eg:
//activity_main
//imageview_test
removeConvertedLayout false
//default config above
buildType {
debug { //the default option will be used for values that are not set
Expand Down Expand Up @@ -184,7 +189,7 @@ no need

#### 2. ~~Increase the build time~~ and increase linearly according to the number of layouts, after first time, the build will use cache

#### 3. Increase the raw size of APK. When there are 52 layout files in the demo, the size of release APK increases by about 38K. The option of repackaging and removing converted layout files may be added later
#### 3. Increase the raw size of APK. When there are 52 layout files in the demo, the size of release APK increases by about 38K. ~~The option of repackaging and removing converted layout files may be added later~~, use removeConvertedLayout option to remove converted layout file with version 3.4.0 above, and you should add layout info that qxml can not deal to the qxmlRemoveLayoutWhiteList.txt, like use the dynamic add ViewStub#setLayoutResource

#### 4. ~~The extension of view needs to use fully qualified class names, which may be improved in the future~~, There is no need for fully qualified class names other than defining shared variables

Expand Down
4 changes: 2 additions & 2 deletions androidx-test/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
//apply plugin: 'kotlin-kapt'

apply plugin: 'com.qxml.code.plugin'

Expand Down Expand Up @@ -91,7 +91,7 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

kapt deps.qxml.processorConstant
annotationProcessor deps.qxml.processorConstant
implementation deps.qxml.dynamic_androidxLib

api deps.qxml.constantConstant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ class AndroidxFragmentTestActivity: FragmentActivity() {
val fragmentTopTv1 = (fl_top.getChildAt(0) as ViewGroup).getChildAt(0)
val fragmentTopTv2 = (fl_top.getChildAt(0) as ViewGroup).getChildAt(1)

LogUtil.e("f top "+fragmentTopTv1+" "+fragmentTopTv1.tag+" "+fragmentTopTv1.id+" "+ R.id.fragment_out_top)
LogUtil.e("f top "+fragmentTopTv2+" "+fragmentTopTv2.tag+" "+fragmentTopTv2.id+" "+ R.id.fragment_include_top2)
LogUtil.e("top "+fragmentTopTv1+" "+fragmentTopTv1.tag+" "+fragmentTopTv1.id+" "+ R.id.fragment_out_top)
LogUtil.e("top "+fragmentTopTv2+" "+fragmentTopTv2.tag+" "+fragmentTopTv2.id+" "+ R.id.fragment_include_top2)
val fragmentBottomTv1 = (fl_bottom.getChildAt(0) as ViewGroup).getChildAt(0)
val fragmentBottomTv2 = (fl_bottom.getChildAt(0) as ViewGroup).getChildAt(1)

//LogUtil.e("f fragments "+supportFragmentManager.fragments)
//LogUtil.e("fragments "+supportFragmentManager.fragments)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class Constants {
const val ATTR_NAME_LAYOUT_WIDTH = "layout_width"
const val ATTR_NAME_LAYOUT_HEIGHT = "layout_height"
const val ATTR_NAME_ID = "id"
const val ATTR_NAME_LAYOUT = "layout"
const val ATTR_NAME_NAME = "name"
const val ATTR_NAME_TAG = "tag"
const val ATTR_PREFIX_ANDROID = "android"
Expand Down Expand Up @@ -99,6 +100,7 @@ class Constants {

const val LAYOUT_CLASS = "class"
const val LAYOUT_LAYOUT = "layout"
const val ANDROID_ATTR_LAYOUT = "android:layout"
const val LAYOUT_STYLE = "style"
const val LAYOUT_THEME = "android:theme"

Expand Down Expand Up @@ -133,8 +135,12 @@ class Constants {
const val QXML_STYLE_CACHE_FILE_NAME = "qxml_style_info.txt"
const val QXML_LAYOUT_CACHE_DIR_NAME = "layout"
const val QXML_LAYOUT_CACHE_FILE_NAME = "qxml_layout_info.txt"
const val QXML_LAYOUT_INFO_CACHE_DIR_NAME = "layoutInfo"
const val QXML_LAYOUT_INFO_CACHE_FILE_NAME = "layoutInfo.txt"
const val QXML_RELATIVE_INCLUDE_LAYOUT_INFO_CACHE_FILE_NAME = "relativeLayoutInfo.txt"
const val QXML_VIEW_GEN_INFO_CACHE_FILE_NAME = "qxml_view_gen_info.txt"
const val QXML_METHOD_CONTENT_CACHE_FILE_NAME = "methodContent.txt"
const val QXML_REMOVE_LAYOUT_WHITE_LIST_FILE_NAME = "qxmlRemoveLayoutWhiteList.txt"

const val INTERMEDIATES = "intermediates"
const val BUILD = "build"
Expand Down
Loading

0 comments on commit 7dd510e

Please sign in to comment.