Show page progress on ProgressIndicator

pull/118/head
Koitharu 4 years ago
parent e1285fe738
commit 9686ad6f00
No known key found for this signature in database
GPG Key ID: 8E861F8CE6E7CE27

@ -44,12 +44,16 @@ open class PageHolder(
override fun onLoadingStarted() { override fun onLoadingStarted() {
binding.layoutError.isVisible = false binding.layoutError.isVisible = false
binding.progressBar.isVisible = true binding.progressBar.isVisible = true
binding.textViewProgress.isVisible = true
binding.ssiv.recycle() binding.ssiv.recycle()
} }
override fun onProgressChanged(progress: Int) { 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) { override fun onImageReady(uri: Uri) {
@ -94,7 +98,6 @@ open class PageHolder(
override fun onImageShown() { override fun onImageShown() {
binding.progressBar.isVisible = false binding.progressBar.isVisible = false
binding.textViewProgress.isVisible = false
} }
override fun onClick(v: View) { override fun onClick(v: View) {
@ -110,6 +113,5 @@ open class PageHolder(
) )
binding.layoutError.isVisible = true binding.layoutError.isVisible = true
binding.progressBar.isVisible = false binding.progressBar.isVisible = false
binding.textViewProgress.isVisible = false
} }
} }

@ -44,12 +44,16 @@ class WebtoonHolder(
override fun onLoadingStarted() { override fun onLoadingStarted() {
binding.layoutError.isVisible = false binding.layoutError.isVisible = false
binding.progressBar.isVisible = true binding.progressBar.isVisible = true
binding.textViewProgress.isVisible = true
binding.ssiv.recycle() binding.ssiv.recycle()
} }
override fun onProgressChanged(progress: Int) { 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) { override fun onImageReady(uri: Uri) {
@ -73,7 +77,6 @@ class WebtoonHolder(
override fun onImageShown() { override fun onImageShown() {
binding.progressBar.isVisible = false binding.progressBar.isVisible = false
binding.textViewProgress.isVisible = false
} }
override fun onClick(v: View) { override fun onClick(v: View) {
@ -89,7 +92,6 @@ class WebtoonHolder(
) )
binding.layoutError.isVisible = true binding.layoutError.isVisible = true
binding.progressBar.isVisible = false binding.progressBar.isVisible = false
binding.textViewProgress.isVisible = false
} }
fun getScrollY() = binding.ssiv.getScroll() fun getScrollY() = binding.ssiv.getScroll()

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

@ -19,15 +19,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" /> 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 <TextView
android:id="@+id/textView_number" android:id="@+id/textView_number"
android:layout_width="wrap_content" android:layout_width="wrap_content"

@ -21,15 +21,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" /> 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 <LinearLayout
android:id="@+id/layout_error" android:id="@+id/layout_error"
android:layout_width="wrap_content" android:layout_width="wrap_content"

Loading…
Cancel
Save