Skip to content

Commit ea501ad

Browse files
committed
2 parents 7892527 + 938d1fc commit ea501ad

File tree

2 files changed

+62
-2
lines changed

2 files changed

+62
-2
lines changed

.github/workflows/android.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Android CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: set up JDK 1.8
17+
uses: actions/setup-java@v1
18+
with:
19+
java-version: 1.8
20+
- name: Build with Gradle
21+
run: ./gradlew build

README.md

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,41 @@
1-
# android-lazy-load-component
2-
A component to help lazy load any view component (using layout resource ID). It inflate the layout when it is shown in the viewport seen by user
1+
# Android Lazy Load Component
2+
A component view to help lazy load any view component (using layout resource ID). It inflate the layout when it is shown in the viewport seen by user. Thus, it helps to reduce layout startup time by inflating layout view lazyily.
3+
4+
Disclaimer: For better visual purpose, this demo uses 1 second of delay and color to help you to understand how this lazy load component works
5+
6+
![Demo](https://github.com/WendyYanto/android-lazy-load-component/blob/master/assets/demo.gif)
7+
8+
## Implementation Steps
9+
10+
1. This library has already been included in jitpack.io. In order to use it, you should add it in your root build.gradle at the end of repositories:
11+
```
12+
allprojects {
13+
repositories {
14+
...
15+
maven { url 'https://jitpack.io' }
16+
}
17+
}
18+
```
19+
2. Add the dependency
20+
```
21+
dependencies {
22+
implementation 'com.github.WendyYanto:android-lazy-load-component:v1.0.0'
23+
}
24+
```
25+
3. Include LazyLoadComponent in your XML layout (best recommended to use in `ScrollView`)
26+
```xml
27+
<dev.wendyyanto.library.LazyLoadComponent
28+
android:layout_width="match_parent"
29+
android:layout_height="10dp" />
30+
```
31+
4. Add the required attribute at LazyLoadComponent:
32+
- `app:layout_id`: The layout that is intended to be loaded lazily at runtime
33+
- `app:parent_layout_id`: The root layout's ID (it is used for LazyLoadComponent to decide when to load at runtime if only it's already on the viewport or beyond)
34+
35+
```xml
36+
<dev.wendyyanto.library.LazyLoadComponent
37+
android:layout_width="match_parent"
38+
android:layout_height="10dp"
39+
app:layout_id="@layout/layout_you_want_to_load_lazyily"
40+
app:parent_layout_id="@id/root_layout_id" />
41+
```

0 commit comments

Comments
 (0)