Skip to content

Commit 20b165a

Browse files
author
TimChen
committed
fix: 修正 attribute 命名
1 parent b224ee3 commit 20b165a

File tree

5 files changed

+31
-14
lines changed

5 files changed

+31
-14
lines changed

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ loadingView.listener = object : LoadingView.OnLoadingViewListener {
4848
}
4949
```
5050

51-
### call startLoading function
51+
### Call startLoading function
5252

5353
call startLoading() before you start some data request
5454

@@ -57,7 +57,7 @@ loadingView.startLoading()
5757
presenter.loadData() // or viewModel.loadData()
5858
```
5959

60-
### call finishLoading function
60+
### Call finishLoading function
6161

6262
call finishLoading() when you finishing the work, and give it a result to let loadingView decide which view should be shown
6363

@@ -69,6 +69,19 @@ loadingView.finishLoading(true)
6969
loadingView.finishLoading(false)
7070
```
7171

72+
### Custom text and ui color
73+
74+
```xml
75+
<com.timchentw.loadingview.LoadingView
76+
android:id="@+id/loading_view"
77+
android:layout_width="match_parent"
78+
android:layout_height="match_parent"
79+
app:error_text="目前無法取得資料\n請確認網路狀態後再重新整理"
80+
app:loading_text="@string/loading"
81+
app:progress_color="#998800"
82+
app:refresh_tint="@color/colorPrimary" />
83+
```
84+
7285
## LICENSE
7386

7487
``` text

app/src/main/java/com/example/timchentw/loadingview/MainActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class MainActivity : AppCompatActivity(), LoadingView.OnLoadingViewListener {
2727
}
2828

2929
private fun startTimer() {
30-
disposable = Observable.timer(5000, TimeUnit.MILLISECONDS)
30+
disposable = Observable.timer(2000, TimeUnit.MILLISECONDS)
3131
.observeOn(AndroidSchedulers.mainThread())
3232
.subscribe {
3333
// do something data received

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
xmlns:tools="http://schemas.android.com/tools"
44
android:layout_width="match_parent"
55
android:layout_height="match_parent"
6+
xmlns:app="http://schemas.android.com/apk/res-auto"
67
android:orientation="vertical"
78
tools:context=".MainActivity">
89

@@ -16,6 +17,9 @@
1617
<com.timchentw.loadingview.LoadingView
1718
android:id="@+id/loadingView"
1819
android:layout_width="match_parent"
19-
android:layout_height="match_parent"/>
20+
android:layout_height="match_parent"
21+
app:error_text="@string/hint_no_data_please_check_later"
22+
app:progress_color="#998800"
23+
app:refresh_tint="@color/colorPrimary"/>
2024

2125
</LinearLayout>

loadingview/src/main/java/com/timchentw/loadingview/LoadingView.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ class LoadingView : LinearLayoutCompat {
4747

4848
private fun init(attrs: AttributeSet?) {
4949

50-
val attributes = context.theme.obtainStyledAttributes(attrs, R.styleable.LoadingView, 0, 0)
50+
val attributes = context.theme.obtainStyledAttributes(attrs, R.styleable.loading_view, 0, 0)
5151
try{
5252
// load attributes
53-
progressColor = attributes.getColor(R.styleable.LoadingView_progressColor, DEFAULT_PROGRESS_COLOR)
54-
refreshTint = attributes.getColor(R.styleable.LoadingView_refreshTint, DEFAULT_REFRESH_TINT)
55-
errorText = attributes.getString(R.styleable.LoadingView_errorText)
56-
loadingText = attributes.getString(R.styleable.LoadingView_loadingText)
53+
progressColor = attributes.getColor(R.styleable.loading_view_progress_color, DEFAULT_PROGRESS_COLOR)
54+
refreshTint = attributes.getColor(R.styleable.loading_view_refresh_tint, DEFAULT_REFRESH_TINT)
55+
errorText = attributes.getString(R.styleable.loading_view_error_text)
56+
loadingText = attributes.getString(R.styleable.loading_view_loading_text)
5757
} finally {
5858
attributes.recycle()
5959
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
33

4-
<declare-styleable name = "LoadingView">
5-
<attr name = "progressColor" format = "color" />
6-
<attr name = "refreshTint" format = "color" />
7-
<attr name = "errorText" format = "string" />
8-
<attr name = "loadingText" format = "string" />
4+
<declare-styleable name = "loading_view">
5+
<attr name = "progress_color" format = "color" />
6+
<attr name = "refresh_tint" format = "color" />
7+
<attr name = "error_text" format = "string" />
8+
<attr name = "loading_text" format = "string" />
99
</declare-styleable>
1010
</resources>

0 commit comments

Comments
 (0)