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

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmed7official committed Jan 11, 2020
1 parent 1ce532a commit 674576e
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 43 deletions.
4 changes: 2 additions & 2 deletions statelayout/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
defaultConfig {
minSdkVersion 21
targetSdkVersion 29
versionCode 2
versionName "0.0.2"
versionCode 3
versionName "0.0.3"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ package com.github.ahmed7official.statelayout

import android.animation.LayoutTransition
import android.content.Context
import android.content.res.ColorStateList
import android.graphics.Color
import android.os.Parcelable
import android.util.AttributeSet
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import android.widget.*
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.ContextCompat
import androidx.core.view.children
Expand All @@ -34,22 +33,6 @@ class StateLayout @JvmOverloads constructor(
}//lazy


// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

override fun onSaveInstanceState(): Parcelable? {
return super.onSaveInstanceState()
//TODO:
}//onSaveInstanceState()

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

override fun onRestoreInstanceState(state: Parcelable?) {
super.onRestoreInstanceState(state)
//TODO:
}//onRestoreInstanceState()

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

override fun onFinishInflate() {
super.onFinishInflate()

Expand Down Expand Up @@ -92,12 +75,18 @@ class StateLayout @JvmOverloads constructor(
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

fun stateLoading(
loadingMessage: String = "Loading, please wait",
backgroundColor: Int = R.color.colorPrimaryDark
message: String = "Loading, please wait",
messageColor: Int = android.R.color.darker_gray,
backgroundColor: Int = android.R.color.white
) {
Log.i("zxc", "stateLoading()")

layoutLoading.findViewById<TextView>(R.id.tvLoading).text = loadingMessage
layoutLoading.findViewById<TextView>(R.id.tvLoading).apply {
text = message
setTextColor(ContextCompat.getColor(context, messageColor))
}

layoutLoading.findViewById<ProgressBar>(R.id.progressBar).progressBackgroundTintList = ColorStateList.valueOf(Color.GRAY)

layoutLoading.findViewById<LinearLayout>(R.id.layoutLoading).setBackgroundColor(ContextCompat.getColor(context, backgroundColor))


Expand Down
8 changes: 4 additions & 4 deletions statelayout/src/main/res/layout/layout_error.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
android:id="@+id/layoutError"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="24dp"
android:background="@color/colorPrimaryDark"
android:clickable="true"
android:focusable="true">
android:focusable="true"
android:padding="24dp">


<LinearLayout
Expand All @@ -31,9 +31,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
tools:text="Internal Server Error"
android:textColor="@android:color/white"
android:textSize="24sp" />
android:textSize="24sp"
tools:text="Internal Server Error" />


</LinearLayout>
Expand Down
7 changes: 4 additions & 3 deletions statelayout/src/main/res/layout/layout_loading.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@


<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
android:id="@+id/progressBar"
android:layout_width="35dp"
android:layout_height="35dp" />


<TextView
android:layout_marginTop="8dp"
android:text="Loadint"
android:text="@string/loading"
android:id="@+id/tvLoading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
Expand Down
1 change: 1 addition & 0 deletions statelayout/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ Praesent faucibus ac mi nec tincidunt. Vivamus pulvinar mattis dui. Curabitur eu
<string name="something_went_wrong">Something went wrong</string>
<string name="icon">icon</string>
<string name="retry">retry</string>
<string name="loading">loading</string>

</resources>
11 changes: 1 addition & 10 deletions statelayout/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
<resources>

<!-- Base application theme. -->
<style name="StateLayoutTheme" parent="Theme.MaterialComponents.Light.NoActionBar.Bridge">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>


</style>



</resources>

0 comments on commit 674576e

Please sign in to comment.