Skip to content

Commit 6118649

Browse files
committed
优化代码
1 parent 9970dc9 commit 6118649

11 files changed

Lines changed: 41 additions & 7 deletions

File tree

app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ dependencies {
3232
implementation "androidx.recyclerview:recyclerview:1.1.0"
3333
implementation 'com.github.li-xiaojun:EasyAdapter:1.2.4'
3434
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
35+
implementation 'com.airbnb.android:lottie:3.5.0'
3536
implementation project(':statelayout-library')
3637
}

app/src/main/java/com/lxj/demo1/MainActivity.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ class MainActivity : AppCompatActivity() {
4343

4444
// create StateLayout for textView
4545
val layout2 = StateLayout(this)
46-
.config(retryAction = {
46+
.config(
47+
loadingLayoutId = R.layout.layout_loading,
48+
retryAction = {
4749
Toast.makeText(this, "点击了重试", Toast.LENGTH_SHORT).show()
4850
})
4951
.wrap(view_content)

app/src/main/res/layout/activity_main.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
tools:context="com.lxj.demo1.MainActivity">
1313

1414

15+
<include layout="@layout/layout_loading"/>
16+
17+
1518
<Button
1619
android:id="@+id/btn_loading"
1720
android:layout_width="match_parent"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"-->
3+
<!-- xmlns:app="http://schemas.android.com/apk/res-auto"-->
4+
<!-- android:layout_width="match_parent"-->
5+
<!-- android:layout_height="match_parent">-->
6+
7+
<com.airbnb.lottie.LottieAnimationView xmlns:android="http://schemas.android.com/apk/res/android"
8+
xmlns:app="http://schemas.android.com/apk/res-auto"
9+
android:layout_width="60pt"
10+
android:layout_height="60pt"
11+
android:layout_gravity="center"
12+
android:layout_margin="5pt"
13+
app:lottie_autoPlay="true"
14+
app:lottie_fileName="lottie/refresh.json"
15+
app:lottie_imageAssetsFolder="lottie/refresh"
16+
app:lottie_loop="true"
17+
app:lottie_speed="1" />
18+
19+
<!--</FrameLayout>-->
-2.98 KB
Binary file not shown.
-4.91 KB
Binary file not shown.
-2.05 KB
Binary file not shown.
-2.79 KB
Binary file not shown.
-4.46 KB
Binary file not shown.
-6.93 KB
Binary file not shown.

0 commit comments

Comments
 (0)