Show page progress on ProgressIndicator

This commit is contained in:
Koitharu
2022-03-07 12:42:22 +02:00
parent e1285fe738
commit 9686ad6f00
5 changed files with 13 additions and 26 deletions

View File

@@ -44,12 +44,16 @@ open class PageHolder(
override fun onLoadingStarted() {
binding.layoutError.isVisible = false
binding.progressBar.isVisible = true
binding.textViewProgress.isVisible = true
binding.ssiv.recycle()
}
override fun onProgressChanged(progress: Int) {
binding.textViewProgress.text = if (progress in 0..100) "%d%%".format(progress) else null
if (progress in 0..100) {
binding.progressBar.isIndeterminate = false
binding.progressBar.setProgressCompat(progress, true)
} else {
binding.progressBar.isIndeterminate = true
}
}
override fun onImageReady(uri: Uri) {
@@ -94,7 +98,6 @@ open class PageHolder(
override fun onImageShown() {
binding.progressBar.isVisible = false
binding.textViewProgress.isVisible = false
}
override fun onClick(v: View) {
@@ -110,6 +113,5 @@ open class PageHolder(
)
binding.layoutError.isVisible = true
binding.progressBar.isVisible = false
binding.textViewProgress.isVisible = false
}
}

View File

@@ -44,12 +44,16 @@ class WebtoonHolder(
override fun onLoadingStarted() {
binding.layoutError.isVisible = false
binding.progressBar.isVisible = true
binding.textViewProgress.isVisible = true
binding.ssiv.recycle()
}
override fun onProgressChanged(progress: Int) {
binding.textViewProgress.text = if (progress in 0..100) "%d%%".format(progress) else null
if (progress in 0..100) {
binding.progressBar.isIndeterminate = false
binding.progressBar.setProgressCompat(progress, true)
} else {
binding.progressBar.isIndeterminate = true
}
}
override fun onImageReady(uri: Uri) {
@@ -73,7 +77,6 @@ class WebtoonHolder(
override fun onImageShown() {
binding.progressBar.isVisible = false
binding.textViewProgress.isVisible = false
}
override fun onClick(v: View) {
@@ -89,7 +92,6 @@ class WebtoonHolder(
)
binding.layoutError.isVisible = true
binding.progressBar.isVisible = false
binding.textViewProgress.isVisible = false
}
fun getScrollY() = binding.ssiv.getScroll()

View File

@@ -166,6 +166,7 @@ inline fun <reified T> RecyclerView.ViewHolder.getItem(): T? {
return ((this as? AdapterDelegateViewBindingViewHolder<*, *>)?.item as? T)
}
@Deprecated("Useless")
fun BaseProgressIndicator<*>.setIndeterminateCompat(indeterminate: Boolean) {
if (isIndeterminate != indeterminate) {
if (indeterminate && visibility == View.VISIBLE) {

View File

@@ -19,15 +19,6 @@
android:layout_height="wrap_content"
android:layout_gravity="center" />
<TextView
android:id="@+id/textView_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.Material3.LabelSmall"
tools:text="146%" />
<TextView
android:id="@+id/textView_number"
android:layout_width="wrap_content"

View File

@@ -21,15 +21,6 @@
android:layout_height="wrap_content"
android:layout_gravity="center" />
<TextView
android:id="@+id/textView_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.Material3.LabelSmall"
tools:text="146%" />
<LinearLayout
android:id="@+id/layout_error"
android:layout_width="wrap_content"