Skip to content

🎱 Android 性能优化:布局预加载,提前 AsyncInflater Layout,用于提升布局加载速度

Notifications You must be signed in to change notification settings

JarvisGG/PreInflater

Repository files navigation

PreInflater

Platform SDK

Android 性能优化:布局预加载,提前 AsyncInflater Layout,用于提升布局加载速度


Author Jarvis
E-mail yang4130qq@gmail.com

Usage

Step 1:

buildscript {
    repositories {
        // ...
        jcenter()
        maven { url 'https://jitpack.io' }
    }
        
    dependencies {
        // ...
        classpath 'com.github.JarvisGG.PreInflater:buildSrc:1.0-SNAPSHORT'
        classpath "com.jakewharton:butterknife-gradle-plugin:9.0.0"
    }
}

Step2:

apply plugin: 'preinflater-plugin'
apply plugin: 'com.jakewharton.butterknife'

repositories {
    // ...
    maven { url "https://jitpack.io" }
}

dependencies {
    api 'com.github.JarvisGG.PreInflater:annotation:1.0.2-SNAPSHORT'
    annotationProcessor 'com.github.JarvisGG.PreInflater:compiler:1.0.2-SNAPSHORT'
    
    api 'com.github.JarvisGG.PreInflater:library:1.0.2-SNAPSHORT'
}

Step3:

android {
    // ...
    defaultConfig {
        // ...
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = [
                     moduleNameOfPreInflater: 'testmodule1'
                ]
            }
        }
    }
    // ...
}

假如希望对当前 Activity 的加载布局都可以使用预加载,需要在 Activity 加一个 空方法,preinflater-plugin 插件会帮你 hook 这个方法,并替换你的 LayoutInflater

@Override
protected void attachBaseContext(Context newBase) {
}

Tip

star star star !!!!:blush:

LICENSE

This library is under the MIT license. check the LICENSE file for more detail.

Copyright (c) 2019 Jarvis

About

🎱 Android 性能优化:布局预加载,提前 AsyncInflater Layout,用于提升布局加载速度

Resources

Stars

Watchers

Forks

Packages

No packages published