Skip to content

1.1.1

Choose a tag to compare

@donglua donglua released this 17 Jun 09:56
· 19 commits to main since this release

LayoutX2C 1.1.1

🐛 Bug Fixes

DataBinding ImageView src attribute support

Problem: When using android:src="@{icon}" with DataBinding, the icon was not displayed because the binding code was not being generated.

Root Cause: The ImageSourceAttributeHandler.supportsValue() method rejected DataBinding expressions like "@{icon}" because isSupportedDrawableReference() returned false. This caused android:src to be marked as 'unsupported' instead of 'dataBinding', preventing the binding code from being generated in executeBindings().

Solution: Modified ImageSourceAttributeHandler.supportsValue() to accept DataBinding expressions (@{} and @={}). DataBinding expressions are now validated at runtime via executeBindings() rather than at compile time.

Impact:

  • ✅ android:src="@{icon}" now correctly generates viewIcon.setImageResource(icon ?: 0)
  • ✅ Static drawable references (@drawable/xxx) continue to work
  • ✅ Theme attribute references (?attr/xxx) continue to work

📝 Changes

Commits

  • cbcb2aa fix: support DataBinding expressions in ImageView android:src attribute
  • 7894da7 test: fix ImageViewSrcBindingTest array index out of bounds
  • 697d204 docs(release): split 1.1.0 notes by language
  • 5c9a49e docs(release): polish 1.1.0 notes

Modified Files

  • compiler-core/src/main/kotlin/com/github/donglua/layoutx2c/registry/ViewRegistry.kt
  • compiler-core/src/test/kotlin/com/github/donglua/layoutx2c/codegen/ImageViewSrcBindingTest.kt
  • Release documentation improvements

📦 Installation

Gradle (Kotlin DSL)

dependencies {
    ksp("com.github.donglua:layoutx2c-ksp:1.1.1")
    implementation("com.github.donglua:layoutx2c-runtime:1.1.1")
}

Gradle (Groovy)

dependencies {
    ksp 'com.github.donglua:layoutx2c-ksp:1.1.1'
    implementation 'com.github.donglua:layoutx2c-runtime:1.1.1'
}

🔍 How to Verify

After updating to 1.1.1 and rebuilding your project, check the generated binding code:

Before (1.1.0):

protected override fun executeBindings() {
    if (dirtyFlags != 0L) {
        viewText.setText(text ?: "")
        // ❌ Missing: viewIcon.setImageResource(icon ?: 0)
    }
}

After (1.1.1):

protected override fun executeBindings() {
    if (dirtyFlags != 0L) {
        viewText.setText(text ?: "")
        viewIcon.setImageResource(icon ?: 0)  // ✅ Now generated
    }
}

📖 Full Changelog

v1.1.0...v1.1.1

1.1.0...1.1.1