Skip to content
This repository was archived by the owner on Jun 3, 2023. It is now read-only.

Commit 674576e

Browse files
improvements
1 parent 1ce532a commit 674576e

File tree

6 files changed

+25
-43
lines changed

6 files changed

+25
-43
lines changed

statelayout/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ android {
1414
defaultConfig {
1515
minSdkVersion 21
1616
targetSdkVersion 29
17-
versionCode 2
18-
versionName "0.0.2"
17+
versionCode 3
18+
versionName "0.0.3"
1919

2020
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2121
consumerProguardFiles 'consumer-rules.pro'

statelayout/src/main/java/com/github/ahmed7official/statelayout/StateLayout.kt

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@ package com.github.ahmed7official.statelayout
22

33
import android.animation.LayoutTransition
44
import android.content.Context
5+
import android.content.res.ColorStateList
6+
import android.graphics.Color
57
import android.os.Parcelable
68
import android.util.AttributeSet
79
import android.util.Log
810
import android.view.LayoutInflater
911
import android.view.View
10-
import android.widget.FrameLayout
11-
import android.widget.ImageView
12-
import android.widget.LinearLayout
13-
import android.widget.TextView
12+
import android.widget.*
1413
import androidx.constraintlayout.widget.ConstraintLayout
1514
import androidx.core.content.ContextCompat
1615
import androidx.core.view.children
@@ -34,22 +33,6 @@ class StateLayout @JvmOverloads constructor(
3433
}//lazy
3534

3635

37-
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
38-
39-
override fun onSaveInstanceState(): Parcelable? {
40-
return super.onSaveInstanceState()
41-
//TODO:
42-
}//onSaveInstanceState()
43-
44-
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
45-
46-
override fun onRestoreInstanceState(state: Parcelable?) {
47-
super.onRestoreInstanceState(state)
48-
//TODO:
49-
}//onRestoreInstanceState()
50-
51-
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
52-
5336
override fun onFinishInflate() {
5437
super.onFinishInflate()
5538

@@ -92,12 +75,18 @@ class StateLayout @JvmOverloads constructor(
9275
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
9376

9477
fun stateLoading(
95-
loadingMessage: String = "Loading, please wait",
96-
backgroundColor: Int = R.color.colorPrimaryDark
78+
message: String = "Loading, please wait",
79+
messageColor: Int = android.R.color.darker_gray,
80+
backgroundColor: Int = android.R.color.white
9781
) {
98-
Log.i("zxc", "stateLoading()")
9982

100-
layoutLoading.findViewById<TextView>(R.id.tvLoading).text = loadingMessage
83+
layoutLoading.findViewById<TextView>(R.id.tvLoading).apply {
84+
text = message
85+
setTextColor(ContextCompat.getColor(context, messageColor))
86+
}
87+
88+
layoutLoading.findViewById<ProgressBar>(R.id.progressBar).progressBackgroundTintList = ColorStateList.valueOf(Color.GRAY)
89+
10190
layoutLoading.findViewById<LinearLayout>(R.id.layoutLoading).setBackgroundColor(ContextCompat.getColor(context, backgroundColor))
10291

10392

statelayout/src/main/res/layout/layout_error.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
android:id="@+id/layoutError"
66
android:layout_width="match_parent"
77
android:layout_height="match_parent"
8-
android:padding="24dp"
98
android:background="@color/colorPrimaryDark"
109
android:clickable="true"
11-
android:focusable="true">
10+
android:focusable="true"
11+
android:padding="24dp">
1212

1313

1414
<LinearLayout
@@ -31,9 +31,9 @@
3131
android:layout_width="wrap_content"
3232
android:layout_height="wrap_content"
3333
android:layout_marginTop="40dp"
34-
tools:text="Internal Server Error"
3534
android:textColor="@android:color/white"
36-
android:textSize="24sp" />
35+
android:textSize="24sp"
36+
tools:text="Internal Server Error" />
3737

3838

3939
</LinearLayout>

statelayout/src/main/res/layout/layout_loading.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010

1111

1212
<ProgressBar
13-
android:layout_width="wrap_content"
14-
android:layout_height="wrap_content" />
13+
android:id="@+id/progressBar"
14+
android:layout_width="35dp"
15+
android:layout_height="35dp" />
1516

1617

1718
<TextView
1819
android:layout_marginTop="8dp"
19-
android:text="Loadint"
20+
android:text="@string/loading"
2021
android:id="@+id/tvLoading"
2122
android:layout_width="wrap_content"
2223
android:layout_height="wrap_content"/>

statelayout/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@ Praesent faucibus ac mi nec tincidunt. Vivamus pulvinar mattis dui. Curabitur eu
3838
<string name="something_went_wrong">Something went wrong</string>
3939
<string name="icon">icon</string>
4040
<string name="retry">retry</string>
41+
<string name="loading">loading</string>
4142

4243
</resources>
Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
<resources>
22

3-
<!-- Base application theme. -->
4-
<style name="StateLayoutTheme" parent="Theme.MaterialComponents.Light.NoActionBar.Bridge">
5-
<!-- Customize your theme here. -->
6-
<item name="colorPrimary">@color/colorPrimary</item>
7-
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
8-
<item name="colorAccent">@color/colorAccent</item>
9-
10-
11-
</style>
12-
3+
134

145
</resources>

0 commit comments

Comments
 (0)