Skip to content

Commit

Permalink
ProgressBar improved.
Browse files Browse the repository at this point in the history
  • Loading branch information
theakashdev committed Nov 26, 2022
1 parent 9c4cff5 commit ee595fd
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 37 deletions.
3 changes: 2 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@

<com.akashdev.kotlinx.XProgressBar
android:id="@+id/progress"
android:background="@color/x_progress_bar_bg_color"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:elevation="10dp"
app:layout_constraintTop_toTopOf="parent"
app:isVisibleLoadingText="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:loadingText="Wait..." />

</androidx.constraintlayout.widget.ConstraintLayout>
31 changes: 0 additions & 31 deletions library/src/main/java/com/akashdev/kotlinx/XProgressBar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ class XProgressBar @JvmOverloads constructor(
typedArray = context.obtainStyledAttributes(it, R.styleable.XProgressBar)

try {
//visibility of progress
binding.mainLayout.isVisible = typedArray.getBoolean(
/* index = */ R.styleable.XProgressBar_isVisible,
/* defValue = */ true
)

//loading text
binding.textLoading.text = typedArray.getString(
/* index = */
Expand All @@ -40,37 +34,12 @@ class XProgressBar @JvmOverloads constructor(
/* index = */ R.styleable.XProgressBar_isVisibleLoadingText,
/* defValue = */ true
)

//background color
binding.mainLayout.setBackgroundColor(
typedArray.getColor(
/* index = */ R.styleable.XProgressBar_backgroundColor,
/* defValue = */ context.getColor(R.color.x_progress_bar_bg_color)
)
)

} finally {
typedArray.recycle()
}
}
}

var isVisible
get() = typedArray.getBoolean(R.styleable.XProgressBar_isVisible, false)
set(value) {
binding.mainLayout.isVisible = value
}

var backgroundColor: Int?
get() = typedArray.getColor(
R.styleable.XProgressBar_backgroundColor,
context.getColor(R.color.x_progress_bar_bg_color)
)
set(value) {
binding.mainLayout.setBackgroundColor(value!!)
}


var loadingText
get() = typedArray.getString(R.styleable.XProgressBar_loadingText)
set(value) {
Expand Down
2 changes: 0 additions & 2 deletions library/src/main/res/layout/x_progress_bar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto">

<RelativeLayout
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/x_progress_bar_bg_color"
android:clickable="true"
android:focusable="true"
android:gravity="center">
Expand Down
4 changes: 1 addition & 3 deletions library/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<resources>
<declare-styleable name="XProgressBar">
<attr name="isVisible" format="boolean" />
<attr name="backgroundColor" format="color" />
<attr name="isVisibleLoadingText" format="boolean" />
<attr name="loadingText" format="string" localization="suggested" />
<attr name="isVisibleLoadingText" format="boolean" />
</declare-styleable>
</resources>

0 comments on commit ee595fd

Please sign in to comment.