GithubHelp home page GithubHelp logo

dreamgyf / fastinflate Goto Github PK

View Code? Open in Web Editor NEW
9.0 1.0 1.0 611 KB

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. 这是一个Android插件,通过在编译期时解析布局xml文件,将LayoutInflater中的反射实例化转成普通的实例化,以此来提高布局加载的性能

License: Apache License 2.0

Kotlin 100.00%
android android-library android-plugin gradle-plugin kotlin kotlinpoet layoutinflater

fastinflate's Introduction

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.

fastinflate's People

Contributors

dreamgyf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

jacksonning

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.