Skip to content

Latest commit

 

History

History
93 lines (66 loc) · 3.04 KB

README.md

File metadata and controls

93 lines (66 loc) · 3.04 KB

Android Kotlin Gradle Maven CI version stars LICENSE

English | 中文

This is an Android plugin, which can improve the performance of layout loading by parsing the layout xml file during the compilation period and converting the reflection instantiation in LayoutInflater into a normal instantiation.

Get Started

Dependencies

  1. Open the setting.gradle file, and make sure that the repositories, gradlePluginPortal and mavenCentral, are configured.
pluginManagement {
    repositories {
        gradlePluginPortal()
        mavenLocal()
        // other repository
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        mavenCentral()
        mavenLocal()
        // other repository
    }
}
  1. Open the build.gradle file of project, and add the FastInflate plugin in the plugins.
plugins {
    id 'com.dreamgyf.android.fastinflate' version '0.1.0-alpha-07' apply false
}
  1. Open the build.gradle file of module, and add the FastInflate plugin in the plugins.
plugins {
    id 'com.dreamgyf.android.fastinflate'
}
  1. Open the build.gradle file of module, and add the FastInflate library in the dependencies.
dependencies {
    implementation 'com.dreamgyf.android.fastinflate:0.1.0-alpha-07'
}

Usage

Just use FastInflate instead LayoutInflater.

// LayoutInflater.from(this).inflate(R.layout.activity_main, null)
FastInflate.from(this).inflate(R.layout.activity_main, null)

Notice

  • The <include /> tag doesn't supported to use theme attribute.

  • The current version is an alpha beta, and have not done compatibility tests for all of the Android versions.

Performance test

After fixing the context problem, the performance drops to the same level as that of the LayoutInflater.

I'll find ways to improve performance in the future.

Repositories

LICENSE

This project uses the Apache-2.0 license.