Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fabianterhorst/fastlayout
Generates a Java Object for your xml layout to reduce inflate time to zero
https://github.com/fabianterhorst/fastlayout
android android-performance java xml-layout
Last synced: 14 days ago
JSON representation
Generates a Java Object for your xml layout to reduce inflate time to zero
- Host: GitHub
- URL: https://github.com/fabianterhorst/fastlayout
- Owner: FabianTerhorst
- License: apache-2.0
- Created: 2016-05-09T17:51:44.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-01-24T03:22:35.000Z (almost 6 years ago)
- Last Synced: 2024-10-15T11:08:16.272Z (29 days ago)
- Topics: android, android-performance, java, xml-layout
- Language: Java
- Homepage:
- Size: 343 KB
- Stars: 443
- Watchers: 25
- Forks: 35
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FastLayout
### Generates a Java Object for your xml layout to reduce inflate time to zero#### This projects methodcount is very low, because everything happens on compile time.
### Add the dependencies
main build.gradle
```groovy
buildscript {
repositories {
jcenter()
}
dependencies {
...
classpath 'io.fabianterhorst:fastlayout-gradle-plugin:0.0.2-alpha37'
...
}
}
```
app build.gradle
```groovy
...
apply plugin: 'fastlayout'
...
```### First create your layout java class
This is needed to filter the layouts you want to compile
```java
//this is compiling all layouts in layout folder
@Layouts(all = true, exclude = {R.layout.sample_item})
//there you can specify the layouts
//@Layouts(layouts = {"activity_main", "fragment_one"})
//@Layouts(ids = {R.layout.activity_main, R.layout.fragment_one})
//this is needed when you want to use the class fields
//@Layouts
public class AppLayouts {
}
```
### Now use the layout inside your Activity for example
```java
public class MainActivity extends AppCompatActivity {@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//when you don´t wanna use the cache you can also just initiate the object
//setContentView(new ActivityMainLayout(this));
//The cache is reusing the object to improve the performance
ActivityMainLayout layout = LayoutCache.getInstance().getLayout(context, LayoutCache.Activity_Main_Layout);
setContentView(layout);
}
}
```
### Limitations
## Specify a id for every view, otherwise the id is generated and can change.